0% found this document useful (0 votes)
5 views55 pages

DBMS LAB PROGRAMS

The document provides a comprehensive guide on creating and managing SQL database tables using Data Definition Language (DDL) and Data Manipulation Language (DML) commands. It includes examples of creating tables with various constraints (primary key, unique, check, not null), inserting, updating, and deleting records, as well as implementing foreign key constraints for referential integrity. Additionally, it covers aggregate functions, group by clauses, and string functions for querying and manipulating data.

Uploaded by

aourclassroom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views55 pages

DBMS LAB PROGRAMS

The document provides a comprehensive guide on creating and managing SQL database tables using Data Definition Language (DDL) and Data Manipulation Language (DML) commands. It includes examples of creating tables with various constraints (primary key, unique, check, not null), inserting, updating, and deleting records, as well as implementing foreign key constraints for referential integrity. Additionally, it covers aggregate functions, group by clauses, and string functions for querying and manipulating data.

Uploaded by

aourclassroom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Ex.

No: 1 Create a database table, add constraints (primary key, unique, check, Not null),
insert rows, update and delete rows using SQL DDL and DML
commands.

DATA DEFINITION LANGUAGE(DDL)

SQL> create table stud(rollno number(15),name varchar(20),total number(15),dept


varchar(20), primary key(rollno));
Table created.
SQL> desc stud;
Name Null? Type

ROLLNO NOT NULL NUMBER(15)


NAME VARCHAR2(20)
TOTAL NUMBER(15)
DEPT VARCHAR2(20)

SQL> alter table stud add(phone number(15));


Table altered.

SQL> desc stud;


Name Null? Type

ROLLNO NOT NULL NUMBER(15)


NAME VARCHAR2(20)
TOTAL NUMBER(15)
DEPT VARCHAR2(20)
PHONE NUMBER(15)

SQL> alter table stud modify(name varchar(30));


Table altered.

SQL> desc stud;


Name Null? Type

ROLLNO NOT NULL NUMBER(15)


NAME VARCHAR2(30)
TOTAL NUMBER(15)
DEPT VARCHAR2(20)
PHONE NUMBER(15)

SQL> alter table stud drop(phone);


Table altered.

SQL> desc stud;


Name Null? Type

ROLLNO NOT NULL NUMBER(15)


NAME VARCHAR2(30)
TOTAL NUMBER(15)
DEPT VARCHAR2(20)
SQL> truncate table stud;
Table truncated.

SQL> drop table stud;


Table dropped.
PRIMARY KEY AS A CONSTRAINT
SQL> create table customer ( cname varchar2(30) not null , cid number(20) not null,
constraint ccd primary key(cname));
Table created.
SQL> insert into customer values ( 'jones', 506);
1 row created.
SQL> insert into customer values ('hayden',508);
1 row created.
SQL> select * from customer;
CNAME CID

jones 506
hayden 508
SQL> alter table customer drop constraint ccd;
Table altered.
SQL> alter table customer add constraint ccdd primary key(cid);
Table altered.
SQL> insert into custo values ('ricky', 508);
insert into custo values ('ricky', 508)
*
ERROR at line 1:
ORA-00001: unique constraint (IICSE111.CCDD) violated
SQL> insert into custo values ('ricky', 509);
1 row created.
SQL> select * from custo;
CNAME CID

jones 506
hayden 508
ricky 509

SQL> create table emply


2 (
3 name varchar (10),
4 salary number(10),
5 sssn number(20),
6 depno number(10),
7 constraint aa primary key(sssn));
Table created.
SQL> insert into emply values ('aaa', 10000, 11, 35);
1 row created.

SQL> insert into emply values ('bbb', 20000, 12, 36);


1 row created.
SQL> insert into emply values ('ccc', 30000, 13, 37);
1 row created.
SQL> select * from emply;
NAME SALARY SSSN DEPNO

aaa 10000 11 35
bbb 20000 12 36
ccc 30000 13 37
SQL> alter table emply disable constraint aa;
Table altered.
SQL> alter table emply enable constraint aa;
Table altered.

NOT NULL CONSTRAINT

SQL> create table empp (ename varchar(30) not null, eid varchar(20) not null);
Table created.
SQL> insert into empp values ('abcde',11);
1 row created.
SQL> insert into empp values ('klmno',null);
insert into empl values ('klmno',null)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("ITA"."EMPL"."EID")
SQL> select * from empl;
ENAME EID

abcde 11
fghij 12

CHECK AS A COLUMN CONSTRAINT

SQL> create table dept ( dname varchar(30) not null, did number(20) not null check
(did<10000));
Table created.
SQL> insert into dept values ('sales ',9876);
1 row created.
SQL> insert into dept values ('accounts',789645);
insert into dept values ('accounts',789645)
*
ERROR at line 1:
ORA-02290: check constraint (ITA.SYS_C003179) violated
SQL> select * from depts;
DNAME DID

sales 9876
marketing 5432

CHECK AS A TABLE CONSTRAINT

SQL> create table airports (aname varchar(30) not null , aid number(20) not null, acity
varchar(30), constraint chcn check( acity in ('chennai','hyderabad','bangalore')));
Table created.
SQL> insert into airports values( 'abcde', 100,'chennai');
1 row created.
1 row created.
SQL> insert into airports values( 'pqrst', 103,'mumbai');
insert into airports values( 'pqrst', 103,'mumbai')
*
ERROR at line 1:
ORA-02290: check constraint (IICSE110.CHCN) violated
SQL> select * from airports;
ANAME AID ACITY

abcde 100 chennai


fghij 101 hyderabad
klmno 102 bangalore
SQL> alter table airports disable constraint chcn;
Table altered.
SQL> alter table airports enable constraint chcn;
Table altered.
SQL> alter table airports drop constraint chcn;
Table altered.
SQL> insert into airports values( 'pqrst', 103,'mumbai');
1 row created.
SQL> select * from airports;
ANAME AID ACITY

abcde 100 chennai


fghij 101 hyderabad
klmno 102 bangalore
pqrst 103 mumbai

SQL> alter table airports add constraint chcnn check ( acity in


('chennai','hyderabad','bangalore',
'goa'));
alter table airports add constraint chcnn check ( acity in ('chennai','hyderabad','bangalore', 'goa'
*
ERROR at line 1:
ORA-02293: cannot validate (IICSE110.CHCNN) - check constraint violated
SQL> alter table airports add constraint chcnn check ( acity in
('chennai','hyderabad','bangalore',
'mumbai', 'goa', 'delhi'));
Table altered.

UNIQUE AS A COLUMN CONSTRAINT


SQL> create table book (bname varchar2(30) not null, bid number(20) primary key);
Table created.
SQL> insert into book values ('bedtime stories',1001);
1 row created.
SQL> insert into book values ('comics',1001);
insert into book values ('comics',1001)
*
ERROR at line 1:
ORA-00001: unique constraint (ITA.SYS_C003130) violated
SQL> select * from book;
BNAME BID
fairy tales 1000
bedtime stories 1001

UNIQUE AS A TABLE CONSTRAINT


SQL> create table orders( oname varchar(30) not null , oid number(20) not null ,
unique(oname,oid));
Table created.
SQL> insert into orders values ('chair', 2005);
1 row created.
SQL> insert into orders values ('chair',2007);
1 row created.
SQL> insert into orders values ('chair', 2005);
insert into orders values ('chair', 2005)
* ERROR at line 1:
ORA-00001: unique constraint (ITA.SYS_C003152) violated

SQL> select * from orders;


ONAME OID

chair 2005
table 2006
chair 2007

DATA MANIPULATION LANGUAGE

SQL> create table std(rollno number(5),name varchar(15),dept varchar(10),totmarks


number(5),primary key(rollno));
Table created.
1. INSERT
SQL> insert into std values(&rollno,'&name','&dept',&totmarks);
Enter value for rollno: 100
Enter value for name: anu
Enter value for dept: cse
Enter value for totmarks: 67
old 1: insert into std values(&rollno,'&name','&dept',&totmarks)
new 1: insert into std values(100,'anu','cse',67)
1 row created.
SQL> /
Enter value for rollno: 200
Enter value for name: amu
Enter value for dept: ece
Enter value for totmarks: 89
old 1: insert into std values(&rollno,'&name','&dept',&totmarks)
new 1: insert into std values(200,'amu','ece',89)
1 row created.
2. DISPLAY
SQL> select *from std;
ROLLNO NAME DEPT TOTMARKS

100 anu cse 67


200 amu ece 89
300 yoga eee 97
400 guna mech 77
500 abi cse 88
SQL> select dept from std;
DEPT

cse
ece
eee
mech
cse

DISPLAY ONLY DISTINCT VALUES


SQL> select distinct dept from std;
DEPT

cse
ece
eee
mech

3. UPDATE
SQL> update std set rollno=600 where name='abi';
1 row updated.
SQL> select *from std;
ROLLNO NAME DEPT TOTMARKS

100 anu cse 69


200 amu ece 89
300 yoga eee 97
400 guna mech 77
600 abi cse 88
4. DELETE
SQL> delete from std where rollno=100;
1 row deleted.
SQL> select *from std;
ROLLNO NAME DEPT TOTMARKS

200 amu ece 89


300 yoga eee 97
400 guna mech 77
600 abi cse 88
Ex. No.: 2 Create a set of Tables, add Foreign Key Constraints and incorporate Referential
Integrity

SQL> create table deps (


2 dno number(10),
3 dname varchar(10),
4 mgrssn number(10),
5 primary key(dno),
6 foreign key (mgrssn) references emply(ssn));
Table created.

SQL> insert into deps values(32, 'admin', 11);


1 row created.

SQL> insert into deps values(33, 'sales', 11);


1 row created.
SQL> insert into deps values(35, 'manufac', 12);
1 row created.
SQL> insert into deps values(36, 'pruchs', null);
1 row created.
SQL> select * from deps;
DNO DNAME MGRSSN

32 admin 11
33 sales 11
35 manufac 12
36 pruchs
SQL> insert into deps values(37, 'pruchs',14);
insert into deps values(37, 'pruchs',14)
*
ERROR at line 1:
ORA-02291: integrity constraint (IICSE110.SYS_C009841) violated - parent key
not found

ON CASCADE
SQL> create table a (name varchar(10), ssn number(20), salary number(30), constraint qq
primary key(ssn));
Table created.
SQL> create table b (depno number(10), dname varchar(20), mssn number(10), constraint
ww primary key(depno), constraint wwc foreign key(mssn) references a (ssn) on delete
cascade);
Table created.

SQL> select * from a;


NAME SSN SALARY

k1 11 100
k2 12 200
k3 13 200
SQL> select * from b;
DEPNO DNAME MSSN

34 sales 11
35 hq 12
36 mkt 13
SQL> alter table a disable constraint qq;
Table altered.
SQL> alter table a enable constraint qq;
Table altered.
SQL> delete from a where ssn=13;
1 row deleted.
SQL> select * from a;
NAME SSN SALARY

k1 11 100
k2 12 200
SQL> select * from b;
DEPNO DNAME MSSN

34 sales 11
35 hq 12
SQL> alter table b drop constraint wwe;
Table altered.
SQL> alter table b add constraint wweq foreign key(mssn) references a(ssn) on delete set
null;
Table altered.
SQL> delete from a where ssn=12;
1 row deleted.
SQL> select * from a;
NAME SSN SALARY

k1 11 100
SQL> select * from b;
DEPNO DNAME MSSN

34 sales 11
35 hq
Ex. No.: 3a SIMPLE QERIES WITH AGGREGATE FUNCTIONS

AGGREGATE FUNCTIONS
SQL> create table cse(name varchar(10), rno number(10), marks number);
Table created.

SQL> select * from cse;


NAME RNO MARKS

anu 1 56
asthika 2 78
balu 3 70
suganya 4 90
suguna 5 67

SQL> select sum(marks) from cse;


SUM(MARKS)

361

SQL> select avg(marks) from cse;


AVG(MARKS)

72.2

SQL> select min(marks) from cse;


MIN(MARKS)

56

SQL> select max(marks) from cse;


MAX(MARKS)

90

SQL> select count(marks) from cse;


COUNT(MARKS)

SQL> select count(*) COUNT_OF_CSE from cse;


COUNT_OF_CSE

5
SQL> select count(*)
from cse
where marks>70;
COUNT(*)

2
GROUP BY CLAUSE
SQL>create table empp(empid number(20), empname varchar(20), dept varchar(10),
salary number(20));

SQL> select * from empp;


EMPID EMPNAME DEPT SALARY

300 warne management 3000


345 harthik production 2000
245 prabu management 3000
360 roshan production 12000
256 ganga management 25000
456 shankar sales 3000
557 prakash sales 5000
7 rows selected.

SQL> select dept, count(*) from empp group by dept;


EMPNAME

ganga
harthik
prabu
prakash
roshan
shankar
warne
7 rows selected.

HAVING CLAUSE
SQL> select salary from empp group by salary having salary>10000;
SALARY

12000
25000

STRING FUNCTIONS
SQL> select upper(dept) DEPARTMENT from empp;
DEPARTMENT

MANAGEMENT
PRODUCTION
MANAGEMENT
PRODUCTION
MANAGEMENT
SALES
SALES
7 rows selected.

SQL> select lower(dept) DEPARTMENT from empp;


DEPARTMENT
management
production
management
production
management
sales
sales
7 rows selected.

SQL> select empid, empname, length(empname) length_of_name from empp;


EMPID EMPNAME LENGTH_OF_NAME

300 warne 5
345 harthik 7
245 prabu 5
360 roshan 6
256 ganga 5
456 shankar 7
557 prakash 7
7 rows selected.

SQL> select substr('Database Management', 10,19) result from dual;


RESULT

Management

SQL> select lpad('DBMS',10,'*') from dual;


LPAD('DBMS

******DBMS

SQL> select initcap('oracle') result from dual;


RESULT

Oracle

SQL> select rpad('DBMS',10,'*') from dual;


RPAD('DBMS

DBMS******

PATTERN MATCHING
SQL> select * from empp;
EMPID EMPNAME DEPT SALARY

300 warne management 3000


345 harthik production 2000
245 prabu management 3000
360 roshan production 12000
256 ganga management 25000
456 shankar sales 3000
557 prakash sales 5000
7 rows selected.

SQL> select empid, empname from empp where empname like '%ar%';

EMPID EMPNAME

300 warne
345 harthik
456 shankar

SQL> select empid, empname from empp where empname like '%h%';
EMPID EMPNAME

345 harthik
360 roshan
456 shankar
557 prakash

SQL> select empid, empname from empp where empname like 'pra%';
EMPID EMPNAME

245 prabu
557 prakash

SQL> select ltrim('**DBMS**','*') FROM DUAL;


LTRIM(

DBMS**

SQL> select rtrim('**DBMS**','*') FROM DUAL;


RTRIM(

**DBMS

SQL> select ltrim('#*#*#*#*DBMS','#*') LTRIM_RESULT from dual;


LTRIM_RESULT

DBMS

CONCATENATION OPERATOR
SQL> select empname ||' belongs to '|| dept ||' department' from empp;
EMPNAME||'BELONGSTO'||DEPT||'DEPARTMENT'

warne belongs to management department


harthik belongs to production department
prabu belongs to management department
roshan belongs to production department
ganga belongs to management department
shankar belongs to sales department
prakash belongs to sales department
7 rows selected.
Ex. No. 3b Query the database tables using different where clause conditions

SQL> select *from std where dept='cse';


ROLLNO NAME DEPT TOTMARKS
- -
100 anu cse 67
500 abi cse 88

BETWEEN OPERATOR
SQL> select * from std where rollno between 200 and 400;
ROLLNO NAME DEPT TOTMARKS
-
200 amu ece 89
300 yoga eee 97
400 guna mech 77

IN PREDICATE
SQL> select * from std where dept in('cse', 'eee', 'mech');
ROLLNO NAME DEPT TOTMARKS
-
100 anu cse 67
300 yoga eee 87
400 guna mech 77
500 abi cse 88

NOT IN PREDICATE
SQL> select * from std where dept not in('cse', 'eee', 'mech');

ROLLNO NAME DEPT TOTMARKS


-
200 amu ece 89

LOGICAL AND OPERATOR


SQL> select * from std where dept='cse' and totmarks>80;
ROLLNO NAME DEPT TOTMARKS
-
500 abi cse 88

LOGICAL OR OPERATOR
SQL> select rollno, name from std where dept='eee' or totmarks>80;
ROLLNO NAME
-
200 amu
300 yoga
500 abi
Ex. No.: 4 Query the database tables and explore sub queries and simple join
operations

NESTED QUERIES

1.SET MEMBERSHIP
SQL> create table stu(sid number(5),sname varchar(10),primary key(sname));
Table created.
SQL> select *from stu;
SID SNAME

101 balu
102 nanthu
103 amutha
104 yoga
105 maha

SQL> create table ac (acno number(5),cname varchar(10),amount number(10),primary


key(cname));
Table created.
SQL> select *from ac;
ACNO CNAME AMOUNT

101 nanthu 2000


200 yoga 3000
203 anu 5000
300 giri 4000
405 faiza 6000
SQL> select *from stu;
SID SNAME

101 balu
102 nanthu
103 amutha
104 yoga
105 maha

1. IN OPERATION
SQL> select essn
from works_on
where (pno, hours) =all (select pno, hours
from works_on
where essn=333445555);
SNAME

nanthu
yoga
2.NOT IN OPERATION
SQL> select sname from stu where sname not in(select cname from ac);
SNAME
balu
amutha
maha

2.SET COMPARISON
SQL> create table empp(empid number(5),empname varchar(10),dept varchar(10),salary
number(10),primar
y key(empid));
Table created.
SQL> select *from empp;
EMPID EMPNAME DEPT SALARY

300 warne management 3000


345 harthik production 2000
245 management management 3000
360 roshan production 12000
256 ganga management 25000

1. GREATER THAN SOME


SQL> select empname
from empp
where salary >all (2000, 12000);
EMPNAME

warne
management
roshan
ganga

2. GREATER THAN OR EQUAL TO SOME


SQL> select empname from empp where salary>=some(select salary from empp where
dept='production');
EMPNAME

warne
harthik
management
roshan
ganga

3. GREATER THAN ANY


SQL> select empname from empp where salary>any(select salary from empp where
dept='production');
EMPNAME

warne
management
roshan
ganga
4. GREATER THAN OR EQUAL TO ANY
SQL> select empname from empp where salary>=any(select salary from empp where
dept='production');
EMPNAME

warne
harthik
management
roshan
ganga
5. GREATER THAN ALL
SQL> select empname from empp where salary>all(select salary from empp where
dept='production');
EMPNAME

ganga

6. LESS THAN ALL


SQL> select empname from empp where salary<all(select salary from empp where
dept='production');
no rows selected
SQL> select empname from empp where salary<all(select salary from empp where
dept='management');
EMPNAME

Harthik

7. EQUAL TO
SQL> select empname from empp where salary=(select max(salary)from empp where
salary<(select max(salary)from empp));
EMPNAME

Roshan

CORRELATED NESTED QUERIES


8.TEST FOR EMPTY RELATION
1. EXISTS
SQL> select *from ac;
ACNO CNAME AMOUNT

101 nanthu 2000


200 yoga 3000
203 anu 5000
300 giri 4000
405 faiza 6000
SQL> select *from stu;
SID SNAME

101 balu
102 nanthu
103 amutha
104 yoga
105 maha
SQL> select sname
from stu
where exists
(select *
from ac
where ac.cname=stu.sname);
SNAME

nanthu
yoga

2. NOT EXISTS
SQL> select sname from stu where not exists(select * from ac where ac.cname=sname);
SNAME

balu
amutha
maha
JOIN QUERIES

SQL> select * from employee;


ENO ENAME JOB MER DNO

111 saketh analyst 444 10


222 sandeep clerk 333 20
333 jagan manager 111 10
444 madhu engineer 222 40

SQL> select * from dep;


DNO DNAME LOC

10 inventory hyd
20 finance bglr
30 HR Mumbai

SQL> select eno,ename,job,dname,loc from employee e, dep d where e.dno=d.dno;


ENO ENAME JOB DNAME LOC

111 saketh analyst inventory hyd


333 jagan manager inventory hyd
222 sandeep clerk finance bglr

Using Clause:
SQL> select eno,ename,job,dname,loc from employee e join dep d using(dno);
ENO ENAME JOB DNAME LOC

111 saketh analyst inventory hyd


333 jagan manager inventory hyd
222 sandeep clerk finance bglr

On Clause:
SQL> select * from employee join dep on(employee.dno= dep.dno);
ENO ENAME JOB DNAME LOC

111 saketh analyst inventory hyd


333 jagan manager inventory hyd
222 sandeep clerk finance bglr

SQL> select eno,ename,job,dname,loc from employee e join dep d on (e.dno>d.dno);


ENO ENAME JOB DNAME LOC

222 sandeep clerk inventory hyd


444 madhu engineer inventory hyd
444 madhu engineer finance bglr
444 madhu engineer HR Mumbai
1. Self Join:
SQL> select e1.eno,e2.ename,e1.job,e2.dno from employee e1,employee e2 where
e1.eno=e2.mer;
ENO ENAME JOB DNO

111 jagan analyst 10


222 madhu clerk 40
333 sandeep manager 20
444 saketh engineer 10
Ex. No.: 5 Natural join, equi join and outer joins

Equijoin:

SQL> select eno,ename,job,dname,loc from employee e, dep d where e.dno=d.dno;


ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
333 jagan manager inventory hyd
222 sandeep clerk finance bglr

Using Clause:
SQL> select eno,ename,job,dname,loc from employee e join dep d using(dno);
ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
333 jagan manager inventory hyd
222 sandeep clerk finance bglr

On Clause:
SQL> select * from employee join dep on(employee.dno= dep.dno);
ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
333 jagan manager inventory hyd
222 ndeep clerk finance bglr

Non-Equijoin:
SQL> select eno,ename,job,dname,loc from employee e join dep d on (e.dno>d.dno);
ENO ENAME JOB DNAME LOC
- - -
222 sandeep clerk inventory hyd
444 madhu engineer inventory hyd
444 madhu engineer finance bglr
444 madhu engineer HR mumbai
Natural Join:

SQL> select * from employee natural join dep;


DNO ENO ENAME JOB MER DNAME LOC
- - -
10 111 saketh analyst 444 inventory hyd
10 333 jagan manager 111 inventory hyd
20 222 sandeep clerk 333 finance bglr
SQL> select eno,ename,job,dname,loc from employee natural join dep;
ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
333 jagan manager inventory hyd
222 sandeep clerk finance bglr

Outer Join:
5.1 Left Outer Join:
SQL> select eno,ename,job,dname,loc from employee e left outer join dep d on(e.dno=d.dno);
ENO ENAME JOB DNAME LOC
- - -
333 jagan manager inventory hyd
111 saketh analyst inventory hyd
222 sandeep clerk finance bglr
444 madhu engineer
Right Outer Join:
SQL> select eno,ename,job,dname,loc from employee e right outer join dep d on(e.dno=d.dno);
ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
222 sandeep clerk finance bglr
333 jagan manager inventory hyd
HR Mumbai
Full Outer Join:
SQL> select eno,ename,job,dname,loc from employee full outer join dep on(employee.dno =
dep.dno);
ENO ENAME JOB DNAME LOC
- - -
333 jagan manager inventory hyd
111 saketh analyst inventory hyd
222 sandeep clerk finance bglr
444 madhu engineer
HR mumbai
SQL> select eno,ename,job,dname,loc from employee natural right outer join dep;
ENO ENAME JOB DNAME LOC
- - -
111 saketh analyst inventory hyd
222 sandeep clerk finance bglr
333 jagan manager inventory hyd
HR mumbai
SQL> select eno,ename,job,dname,loc from employee natural left outer join dep;
ENO ENAME JOB DNAME LOC
- - -
333 jagan manager inventory hyd
111 saketh analyst inventory hyd
222 sandeep clerk finance bglr
444 madhu engineer
Ex. No.: 6a Study of PL/SQL Blocks

SQL> set serveroutput on;


SQL> declare
2 a varchar2(20);
3 begin
4 a:='Hello';
5 dbms_output.put_line(a);
6 end;
7 /
Hello
PL/SQL procedure successfully completed.

SQL> create table sailors(sid number(10),sname varchar(10),rating number(10),age


number(10));
Table created.
SQL> declare
2 sid number(10):=&sid;
3 sname varchar(10):='&sname';
4 rating number(10):=&rating;
5 age number(10):=&age;
6 begin
7 insert into sailors values(sid,sname,rating,age);
8 end;
9 /
Enter value for sid: 1
old 2: sid number(10):=&sid;
new 2: sid number(10):=1;
Enter value for sname: anitha
old 3: sname varchar(10):='&sname';
new 3: sname varchar(10):='anitha';
Enter value for rating: 12
old 4: rating number(10):=&rating;
new 4: rating number(10):=12;
Enter value for age: 25
old 5: age number(10):=&age;
new 5: age number(10):=25;
PL/SQL procedure successfully completed.

SQL> /
Enter value for sid: 2
old 2: sid number(10):=&sid;
new 2: sid number(10):=2;
Enter value for sname: anu
old 3: sname varchar(10):='&sname';
new 3: sname varchar(10):='anu';
Enter value for rating: 13
old 4: rating number(10):=&rating;
new 4: rating number(10):=13;
Enter value for age: 26
old 5: age number(10):=&age;
new 5: age number(10):=26;
PL/SQL procedure successfully completed.
SQL> select * from sailors;
SID SNAME RATING AGE

1 anitha 12 25
2 anu 13 26

To get student details and to print their results:-

SQL> set serveroutput on;


SQL> declare m number(5);
2 begin
3 select student.totmark into m from student where rollno=&rollno;
4 if m>=75 then
5 dbms_output.put_line('Distinction');
6 elsif m>=60 and m<75 then
7 dbms_output.put_line('First Class');
8 elsif m>=50 and m<60 then
9 dbms_output.put_line('Second Class');
10 else
11 dbms_output.put_line('Fail');
12 end if;
13 end;
14 /
Enter value for rollno: 2
old 3: select student.mark into m from student where rollno=&rollno;
new 3: select student.mark into m from student where rollno=2;
Second Class
PL/SQL procedure successfully completed.
SQL> /
Enter value for rollno: 3
old 3: select student.mark into m from student where rollno=&rollno;
new 3: select student.mark into m from student where rollno=3;
First Class
PL/SQL procedure successfully completed.

To print multiplication table:-


SQL> begin
2 for i in 1..15 loop
3 dbms_output.put_line(i||'*2='||i*2);
4 end loop;
5 end;
6 /
1*2=2
2*2=4
3*2=6
4*2=8
5*2=10
6*2=12
7*2=14
8*2=16
9*2=18
10*2=20
11*2=22
12*2=24
13*2=26
14*2=28
15*2=30

PL/SQL procedure successfully completed.


Ex. No.: 6b Procedures and Functions

PROCEDURE:
SQL> Create or replace procedure
1 fib(a in number)as
2 f0 number(2);
3 f1 number(2);
4 f2 number(2);
5 i number(2);
6 begin f0:=-1;
7 f1:=1;
8 for i in 1..a loop
9 f2:=f1+f0;
10 f0:=f1;
11 f1:=f2;
12 dbms_output.put_line(f2);
13 end loop;
14 end;
15 /
Procedure created.
To Execute:
SQL>Exec fib(5);
0
1
1
2
3
PL/SQL procedure successfully completed.

FUNCTIONS
1. Arithmetic operations
SQL>Create or replace function arith(a in out number,b in out number)return number as
1 c number;
2 begin
3 c:=a+b;
4 dbms_output.put_line(„Sum is‟||c);
5 c:=a-b;
6 dbms_output.put_line(„Difference is‟||c);
7 c:=a*b;
8 dbms_output.put_line(„Product is‟||c);
9 return c;
10 end;
11 /
Function created.
SQL> declare
2 x number(2);
3 y number(2);
4 z number(2);
5 begin
6 x:=&x;
7 y:=&y;
8 z:=arith(x,y);
9 end;
10 /
Enter value for x: 6
Old 6: x=&x;
New 6: x:=6;
Enter value for y: 4
Old 7: y:=&y;
New 7: y:=4;
Sum is 10
Difference is 2
Product is 24
PL/SQL procedure successfully completed.
2. Quadratic Functions
SQL> create or replace function quar(a in out number,b in out number,c in out number)return
2 number as
3 d number(2);
4 begin
5 d:=(b*b)-(4*a*c);
6 dbms_output.put_line(“the result is”||d);
7 return d;
8 end;
9 /
Function created.
SQL>declare
1 x number(2);
2 y number(2);
3 z number(2);
4 p number(2);
5 begin
6 x:=&x;
7 y:=&y;
8 z:=&z;
9 p:=quar(x,y,z);
10 end;
11 /
Enter value for x: 2
Old 7:x:=&x;
New 7: x:=2;
Enter value for y: 4
Old 8:y:=&y;
New 8:y:=4;
Enter value for z: 6
Old 9:z:=&z;
New 9:z:=6;
The result is -32
PL/SQL procedure successfully completed.
Ex. No: 7 Data Control Language and Transaction Control Language

DATA CONTROL LANGUAGE

Username: iicse24
SQL> select * from employee;
NAME SSN SALARY DNO

kishore 12345 10000 1


riyath 67890 20000 2
suresh 54321 30000 3
manikandan 9876 40000 3

SQL> grant select, insert on employee to iicse50;


Grant succeeded.

Username: iicse50
SQL> select * from employee;
select * from employee
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> select * from iicse24.employee;


NAME SSN SALARY DNO

kishore 12345 10000 1


riyath 67890 20000 2
suresh 54321 30000 3
manikandan 9876 40000 3

SQL> insert into iicse24.employee values('raju', 3478, 35000, 2);


1 row created.
SQL> select * from iicse24.employee;
NAME SSN SALARY DNO

kishore 12345 10000 1


riyath 67890 20000 2
suresh 54321 30000 3
manikandan 9876 40000 3
raju 3478 35000 2

SQL> delete from iicse24.employee where ssn=12345;


delete from iicse24.employee where ssn=12345
*
ERROR at line 1:
ORA-01031: insufficient privileges

SQL> update iicse24.employee set salary=36000 where ssn=54321;


update iicse24.employee set salary=36000 where ssn=54321
*
ERROR at line 1:
ORA-01031: insufficient privileges

Username: iicse24
SQL> select * from USER_TAB_PRIVS_MADE;

GRANTEE TABLE_NAME

GRANTOR PRIVILEGE GRA HIE

IICSE50 EMPLOYEE
IICSE24 INSERT NO NO
IICSE50 EMPLOYEE
IICSE24 SELECT NO NO

SQL> select * from USER_TAB_PRIVS_RECD;

OWNER TABLE_NAME

GRANTOR PRIVILEGE GRA HIE

IICSE45 LIBRARY
IICSE45 DELETE NO NO
IICSE45 LIBRARY
IICSE45 INSERT NO NO
IICSE45 LIBRARY
IICSE45 SELECT NO NO
OWNER TABLE_NAME

GRANTOR PRIVILEGE GRA HIE

IICSE45 LIBRARY
IICSE45 UPDATE NO NO

SQL> revoke select, insert on employee from iicse50;


Revoke succeeded.

Username: iicse50
SQL> select * from iicse24.employee;
select * from iicse24.employee
*
ERROR at line 1:
ORA-00942: table or view does not exist
TRANSACTION CONTROL LANGUAGE

SQL> insert into class values('gayathri',9);


1 row created.

SQL> commit;
Commit complete.

SQL> update class set name='hema' where id='9';


1 row updated.

SQL> savepoint A;
Savepoint created.

SQL> insert into class values('indu',11);


1 row created.

SQL> savepoint B;
Savepoint created.

SQL> insert into class values('janani',13);


1 row created.

SQL> select * from class;


NAME ID

anitha 1
balaji 2
chitra 3
divya 4
david 5
deena 8
hema 9
indu 11
janani 13

9 rows selected.
SQL> rollback to B;

Rollback complete.

SQL> select * from class;

NAME ID

anitha 1
balaji 2
chitra 3
divya 4
david 5
deena 8
hema 9
indu 11

8 rows selected.

SQL> rollback to A;

Rollback complete.

SQL> select * from class;

NAME ID

anitha 1
balaji 2
chitra 3
divya 4
david 5
deena 8
hema 9

7 rows selected.
Ex. No.: 8 Triggers

SQL> create table result(rno number(5),name varchar(10),mark1 number(5),mark2


number(5),mark3 number(5),total number(5),average number(5),primary key(rno));
Table created.
SQL> create or replace trigger t1 after insert on result
2 begin
3 update result set total=mark1+mark2+mark3;
4 update result set average=total/3;
5 end;
6/
Trigger created.
SQL> insert into result(rno,name,mark1,mark2,mark3)values(105,'vinith',56,96,78);
1 row created.
SQL> select *from result;
RNO NAME MARK1 MARK2 MARK3 TOTAL AVERAGE

101 amutha 67 85 77 229 76


102 nith 55 77 65 197 66
103 yoga 99 68 88 255 85
104 siva 87 67 85 239 80
105 vinith 56 96 78 230 77

SQL> create table student1(rno number(3),name varchar(10),percentage


number(3),primary key(rno));
Table created.
SQL> create table student2(rno number(3),percentage number(3),primary key(rno));
Table created.
SQL> create or replace trigger t2 after insert on student1
2 for each row
3 begin
4 insert into student2 values(:new.rno,:new.percentage);
5 end;
6/
Trigger created.

SQL> insert into student1(rno,name,percentage)values(101,'ganga',88);


1 row created.
SQL> select *from student1;
RNO NAME PERCENTAGE

101 ganga 88
102 abi 80
103 akash 99
104 yuvaraj 88
SQL> select *from student2;
RNO PERCENTAGE

101 88
102 80
103 99
104 88
Ex. No.: 9 View and index for database tables

VIEWS
SQL> select *from emm;
ENO ENAME SALARY DEPNO

7 ashik 23000 12
8 sadhik 34000 10
9 thilaga 24500 15

SQL> select *from depp;


DEPNO ENAME DEPNAME

12 ashik production
10 sadhik service
15 thilga management
1) Creating views:
(i) Create a view named as emm1 on emm table which have eno,ename.
SQL> create view emm1 as select eno,ename from emm;
View created.
SQL> select *from emm1;
ENO ENAME

7 ashik
8 sadhik
9 thilaga
(ii) Create a view named as emm2 from emm table having eno without duplicates:
SQL> create view emm2 as select distinct depno from emm;
View created.
SQL> select *from emm2;
DEPNO

10
12
15
(iii) Create the view to view emm details where depno is 10;
SQL> create view emm3 as select *from emm where depno=10;
View created.
SQL> select *from emm3;
ENO ENAME SALARY DEPNO

8 sadhik 34000 10
(iv) Select the records from the view table
SQL> create view emm11 as select *from em_dep where ename like 's%';
View created.
SQL> select *from emm11;
ENO ENAME SALARY DEPNO DEPNAME

8 sadhik 34000 12 production


8 sadhik 34000 10 service
8 sadhik 34000 15 management
2.DELETING A VIEW:
(i) Delete any view name
SQL> drop view emm2;
View dropped.
(ii) Delete the records from view emm where emm is 12;
SQL> delete from emm4 where depno=12;
1 row deleted.
INDEXES
SQL> create index indx1 on class(id);
Index created.

SQL> create index indx2 on class(id, name);


Index created.

SQL> alter index indx1 rename to inx1;


Index altered.

SQL> drop index indx2;

Index dropped.
Ex. No.: 10 Create an XML database and validate it using XML schema

Program:
XML File (books.xml)
<?xml version="1.0"?>
<x:books xmlns:x="urn:books">
<book id="bk001">
<author>Writer</author>
<title>The First Book</title>
<genre>Fiction</genre>
<price>44.95</price>
<pub_date>2000-10-01</pub_date>
<review>An amazing story of nothing.</review>
</book>
<book id="bk002">
<author>Poet</author>
<title>The Poet's First Poem</title>
<genre>Poem</genre>
<price>24.95</price>
<pub_date>2000-10-01</pub_date>
<review>Least poetic poems.</review>
</book>
</x:books>
XSD File (books.xsd)
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:books"
xmlns:bks="urn:books">
<xsd:element name="books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
<xsd:element name="book"
type="bks:BookForm"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BookForm">
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float" />
<xsd:element name="pub_date" type="xsd:date" />
<xsd:element name="review" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
Ex.No.: 11 Create Document, column and graph based data using NOSQL database tools

Document Based data:


use blog; //create a database ;blog is a database name

db.createCollection('posts') // to create a collection

db.posts.insertOne({ // insert data into the collection


name:'hi',
body:'hi',
address:{
home:'safewdf'
}
})

db.posts.find({}) // to view the data in the collection


const mongoose = require('mongoose'); //import package
function dbConnect() {
mongoose.connect('mongodb://127.0.0.1:27017/myapp').then( d => {
console.log('connected')
}
).catch(e => {
console.log(e)
})
}
dbConnect() //to connect the database
// to create a model called edge
let Edge = mongoose.model('Edge',
{
id: String,
source: { id: String, weight: Number }, target: { id: String, weight: Number } }
)
// to create a model called vertex
let Vertex = mongoose.model('Vertex',
{
id: String,
color: String,
label: String
}
);
// to create a node
async function createNode() {
var vertex = await new Vertex({ cooler: 'red', label: 'red' }); var vertexTwo = await new Vertex({ cooler:
'yellow', label: 'yellow' });
const node = await new Edge({
source: { id: vertex._id, weight: 2 }, target: { id: vertexTwo._id, weight: 4 }, })
await vertex.save()
await vertexTwo.save()
await node.save()
console.log(node)
}
createNode()
Procedure:
1.To install node js-> in windows -> download.

2.show in folder > double click on your node js msi file> next > next > custom set up > node js run time (4
folder) > will be install on local hard drive > next >install.

3.to check the node js:

Cmd> node> “welcome to node js”

4.to install mongo Db

Install mongo db

Window(community edition) > mongo db download center> download >click >install>

5. next>complete>next>install.

6.Finish > Compass> Connect.

7. To install vs code> download>show in folder>double click> I accept>next>next> select additional task>


all>next>next.

//

Cmdline

//

1. mkdir ffolder name)create one folder in c �

2.cd foldername

3.npm init -y

4. Package json is created.

5.goto vs code

file>open folder>fodername

Select folder in c:

6.create file >filename.js >open>code create>save>function call>save.

7.open mongo db

compass>connect>
8.cmd

9.node filename.js

Npm i mongoose)

8.cmd> to crate a folder> mkdir (foldername) sample

Cd sample

/sample> npm init –y

9. package .json file is created.//javascript object notation

10.npm i mongoose

// Added packages detail

11.vs code> new >file> open folder >sample >(index js)

To paste code
12. To run: node
index.js
CREATE
FOLDER IN C:/
Run mongodb
compass
Using command
mkdir fodername
and do
npm init -y
vs code> new >file> open folder > fodername >
1.create file called server.js
//And paste the below code
const express =
require("express");
const app = express();
const TodoTask = require("./models/TodoTask");

app.set("view engine", "ejs");


app.use(express.urlencoded({ extended: true }));
app.use("/static", express.static("public"));

const mongoose = require("mongoose");

mongoose
.connect('mongodb://127.0.0.1:27017/myapp')
.catch((e) => {
console.log(e);
})
.then((_) => {
console.log("Connected to db!");
});

app.get("/", async (req, res) => {


try {
const tasks = await TodoTask.find({});
res.render("todo.ejs", { todoTasks: tasks });
} catch (err) {
console.log(err);
}
});

//POST METHOD
app.post("/", async (req, res) => {
const todoTask = new TodoTask({
content: req.body.content,
});
try {
await todoTask.save();
res.redirect("/");
} catch (err) {
res.redirect("/");
}
});

app.listen(3000, () => console.log("Server Up and running"));

2 > create folder called views


Inside views create file called todo.ejs
And paste the below code
<!DOCT
YPE
html>
<head>
<title>Todo App</title>
<link rel="stylesheet" href="/static/stylesheets/style.css" type="text/css" />
<link
href="https://fonts.googleapis.com/css?family=Baloo+Bhai|Candal|Chewy&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
integrity="sha384-
oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay"
crossorigin="anonymous"
/>
</head>
<body>
<div class="todo-container">
<h2>To-Do List</h2>
<div class="todo">
<form action="/" method="POST" class="todo-header">
<input type="text" name="content" />
<button type="submit"><span class="fas fa-plus"></span></button>
</form>
<ul class="todo-list">
<% todoTasks.forEach(details => { %>
<li class="todo-list-item">
<div class="todo-list-item-name"><%= details.content %></div>
</li>
<% }) %>
</ul>
</div>
</div>
</body>
3 . create folder called public inside public folder create folder called stylesheets
and Inside stylesheets create file called style.css and paste the below code
public-> stylesheets- style.css
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #e27442;
}
.todo-container {
color: white;
position: absolute;
top:50%;
left: 50%;
padding: 20px;
width: 600px;
transform: translate(-50%,-50%);
background: rgba(255, 255, 255, 0.1);
border-radius: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
.todo {
width: 400px;
}
.todo-container h2 {
padding: 10px;
font-family: 'Candal', sans-serif;
font-size: 2em;
}
.todo-header input {
width: 92%;
border: none;
border-radius: 5px;
height: 20px;
font-family: 'Candal', sans-serif;
}
.todo-header button {
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
padding: 5px;
font-family: 'Candal', sans-serif;
background-color: rgb(51, 212, 100);
}
.todo-container ul {
list-style: none;
}
.todo-list-item {
padding: 10px;
margin-top: 10px;
border: none;
border-radius: 5px;
font-family: 'Candal', sans-serif;
background: rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: row;
}
.todo-list-item form {
width: 100%;
display: flex;
}
.todo-list-item input {
flex-grow: 2;
margin-right: 20px;
border: none;
border-radius: 5px;
font-family: 'Candal', sans-serif;
}
.todo-list-item button {
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
padding: 5px;
font-family: 'Candal', sans-serif;
background-color: rgb(51, 212, 100);
}
.todo-list-item .cancel {
color: white;
text-decoration: none;
border: none;
border-radius: 5px;
cursor: pointer;
padding: 5px;
font-family: 'Candal', sans-serif;
background-color: rgb(223, 43, 43);
margin-left: 5px;
}
.todo-list-item div {
flex-grow: 2;
}
.todo-list-item .edit {
color : rgb(143, 233, 58);
margin-right: 10px;
cursor:pointer;
text-decoration: none;
}
.todo-list-item .remove {
color : rgb(243, 96, 96);
margin-right: 5px;
cursor:pointer;
text-decoration: none;
}
4.create folder called model inside model create file called
TodoTask.js
const mongoose =
require("mongoose");
const todoTaskSchema = new mongoose.Schema({
content: {
type: String,
required: true,
},
date: {
type: Date,
default: Date.now,
},
});
module.exports = mongoose.model("TodoTask",
todoTaskSchema);
5. finally come back to the cmd and install required packages by running below code
npm i express ejs mongoose

6. run the app by the help of below command


Node server.js //

7. open localhost:3000 in browser to view the output


Ex.No.: 12a FRONT END TOOLS

Private Sub Command1_Click()


If MsgBox("ADD IT?", vbOKCancel) = vbOK Then
Adodc1.Recordset.AddNew
Else
Adodc1.Recordset.CancelUpdate
End If
End Sub

Private Sub Command2_Click()


If MsgBox("REMOVE IT?", vbOKCancel) = vbOK Then
Adodc1.Recordset.Delete
Else
Adodc1.Recordset.CancelUpdate
End If
End Sub

Private Sub Command3_Click()


If MsgBox("EDIT IT?", vbOKCancel) = vbOK Then
Adodc1.Recordset.Update
Else
Adodc1.Recordset.CancelUpdate
End If
End Sub
FRONT END TOOLS
Ex. No. : 12b FORMS

Private Sub Command1_Click()


Dim a As Integer
a = Val(Text1.Text) + Val(Text2.Text)
MsgBox ("Addition of two numbers" + Str(a))
End Sub

Private Sub Command2_Click()


Dim b As Integer
b = Val(Text1.Text) - Val(Text2.Text)
MsgBox ("Subtraction of two numbers" + Str(b))
End Sub

Private Sub Command3_Click()


Dim c As Integer
c = Val(Text1.Text) * Val(Text2.Text)
MsgBox ("Multiplication of two numbers" + Str(c))
End Sub

Private Sub Command4_Click()


Dim d As Integer
d = Val(Text1.Text) / Val(Text2.Text)
MsgBox ("Division of two numbers" + Str(d))
End Sub
FORMS
Ex. No: 12c MENU DESIGN

Private Sub Open_Click()


MsgBox ("Open")
Form1.BackColor = &H00000000&
End Sub

Private Sub Save_Click()


MsgBox ("Save")
Form1.BackColor = &H008080FF&
End Sub
MENU DESIGN
Ex. No: 12d REPORT GENERATION

Private Sub Command1_Click()


DataReport1.Show
End Sub

Private Sub Command2_Click()


DataReport1.Show
End Sub
Ex. No.:12(e) RAILWAY RESERVATION SYSTEM

Code for Login:


Private Sub Command1_Click()
If Text3.Text = "admin" And Text4.Text = "admin" Then
Unload Me
MDIForm1.Show
Else
MsgBox ("Invalid Username/Password")
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = y
Text2.Text = z
End Sub

Code for Home page:


Private Sub Combo1_Click()
Adodc1.Refresh
Adodc1.Recordset.Find "Train_No =" & Combo1.Text, 0, adSearchForward
If Adodc1.Recordset.EOF = True Then
MsgBox ("Train not Available")
End If
End Sub
Private Sub Command1_Click()
Temp1 = Combo1.Text
Unload Me
Load Form2
Form2.Show
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Code for Reservation:
Dim cn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim cn2 As New ADODB.Connection
Dim rs2 As New ADODB.Recordset
Dim cn3 As New ADODB.Connection
Dim rs3 As New ADODB.Recordset
Dim cn4 As New ADODB.Connection
Dim rs4 As New ADODB.Recordset
Dim cn5 As New ADODB.Connection
Dim rs5 As New ADODB.Recordset
Dim cn6 As New ADODB.Connection
Dim rs6 As New ADODB.Recordset
Private Sub Combo7_Click()
s = "select * from seats where train_no = " & Text1.Text & " AND class = '" & Combo7.Text &
"' "
connect (s)
Set Text66.DataSource = rs
Text66.DataField = "available_seats"
If Text66.Text = "0" Then
MsgBox ("No Seats Available in" & Combo7.Text)
Combo7.Text = ""
End If
End Sub

Private Sub Command1_Click()


If Combo7.Text = "" Then
MsgBox ("Please Select Class")
Exit Sub
End If
If Text11.Text <> "" And Text11.Text <> "0" Then
n1 = Text11.Text
End If
If Text12.Text <> "" And Text12.Text <> "0" Then
n2 = Text12.Text
End If
If Text13.Text <> "" And Text13.Text <> "0" Then
n3 = Text13.Text
End If
If Text14.Text <> "" And Text14.Text <> "0" Then
n4 = Text14.Text
End If
If Text15.Text <> "" And Text15.Text <> "0" Then
n5 = Text15.Text
End If
If Text16.Text <> "" And Text16.Text <> "0" Then
n6 = Text16.Text
End If
Temp2 = Text60.Text
Temp4 = Combo7.Text
Temp6 = Text1.Text
If Text5.Text <> "" And Text11.Text <> "" And Combo1.Text <> "" Then
If Check1.Value = True Then
Text21.Text = "Yes"
Else
Text21.Text = "No"
End If
Text22.Text = DTPicker1.Value
Text23.Text = Combo7.Text
Text67.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs1.Update
rs1.MoveNext
rs1.MovePrevious
End If
If Text6.Text <> "" And Text12.Text <> "" And Combo2.Text <> "" Then
If Check2.Value = True Then
Text28.Text = "Yes"
Else
Text28.Text = "No"
End If
Text29.Text = DTPicker1.Value
Text30.Text = Combo7.Text
Text68.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs2.Update
rs2.MoveNext
rs2.MovePrevious
End If
If Text7.Text <> "" And Text13.Text <> "" And Combo3.Text <> "" Then
If Check3.Value = True Then
Text35.Text = "Yes"
Else
Text35.Text = "No"
End If
Text36.Text = DTPicker1.Value
Text37.Text = Combo7.Text
Text69.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs3.Update
rs3.MoveNext
rs3.MovePrevious
End If
If Text8.Text <> "" And Text14.Text <> "" And Combo4.Text <> "" Then
If Check4.Value = True Then
Text42.Text = "Yes"
Else
Text42.Text = "No"
End If
Text43.Text = DTPicker1.Value
Text44.Text = Combo7.Text
Adodc2.Refresh
Adodc2.Recordset.MoveLast
Text63.Text = Text59 + 1
Text70.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs4.Update
rs4.MoveNext
rs4.MovePrevious
End If
If Text9.Text <> "" And Text15.Text <> "" And Combo5.Text <> "" Then
If Check5.Value = True Then
Text49.Text = "Yes"
Else
Text49.Text = "No"
End If
Text50.Text = DTPicker1.Value
Text51.Text = Combo7.Text
Text71.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs5.Update
rs5.MoveNext
rs5.MovePrevious
End If
If Text10.Text <> "" And Text16.Text <> "" And Combo6.Text <> "" Then
If Check6.Value = True Then
Text56.Text = "Yes"
Else
Text56.Text = "No"
End If
Text57.Text = DTPicker1.Value
Text58.Text = Combo7.Text
Text72.Text = Text66.Text
Text66.Text = Text66.Text - 1
rs.Update
rs.MoveNext
rs.MovePrevious
rs6.Update
rs6.MoveNext
rs6.MovePrevious
End If
Unload Me
Load Form3
Form3.Show
End Sub

Private Sub Command3_Click()


rs1.CancelUpdate
rs2.CancelUpdate
rs3.CancelUpdate
rs4.CancelUpdate
rs5.CancelUpdate
rs6.CancelUpdate
Unload Me
End Sub
RAILWAY RESERVATION SYSTEM
LOGIN:

RESERVATION:

You might also like