Post on 04-Jun-2018
8/13/2019 cs2258 Dbms Record
1/93
8/13/2019 cs2258 Dbms Record
2/93
2
INDEX
S.NO DATE TITLEPAGE
NO
MARKS SIGNATURE
1 18.09.2012CREATION OF BASE TABLES
AND VIEWS3
2 25.09.2012
DATA MANIPULATION USING
INSERT,DELETE AND UPDATE
IN TABLE
13
SELECT,SUB QUERIES ANDJOIN
19
3 09.10.2012 DATA CONTROL COMMANDS 27
4 16.10.2012
HIGH-LEVEL LANGUAGE
EXTENSIONS-PL/SQL OR
TANSACT SQL
36
5 15.11.2012
USE OF
CURSORS,PROCEDURES AND
FUNCTIONS38
6 15.11.2012EMBEDDED SQL OR
DATABASE CONNECTIVITY44
7 22.11.2012ORACLE OR SQL SERVER
TRIGGERS51
8 27.12.2012 WORKING WITH FORMS 57
902.12.2012
WORKING WITH MENUS61
WORKING WITH REPORTS72
10 02.12.2012 FRONT END TOOLS 87
8/13/2019 cs2258 Dbms Record
3/93
3
EXERCISE: 1
DATE:18.09.2012 CREATION OF BASE TABLES AND VIEWS.
AIM:
To create the student table and view the table format .
ALGORITHM:
Step1:Start the program.
Step2:Create the basic tables and insert the values.
Step3:View the table.
Step4:Some functions query was created and view the result.
Step5:Stop the program.
CODING:
SYNTAX :
Create table tablename(column_ name1 datatype, column_ name2 datatype, column_ name
datatype, column_ name4 datatype, column_ name5 datatype, column_ name6 datatype,);
EXAMPLE:
SQL> create table firstmca(stunamevarchar(5),gender
varchar(5),rollnovarchar(5),deptnamevarchar(5),address varchar(8),percent number(10));
RESULT :
Table created.
SYNTAX :
Insert into tablenamevalues(Values_1,Values_2,Values_3,Values_4,Values_5,Values_6);
8/13/2019 cs2258 Dbms Record
4/93
4
EXAMPLE:
SQL> insert into firstmcavalues('gokul','m','01','DBMS','OOTY',85);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into firstmcavalues('mano','m','02','AFM','mumbai',75);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into firstmcavalues('kalai','f','03','DS','Chennai',70);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into firstmcavalues('Vengi','m','04','PSP','London',65);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into firstmca values('sidu','f','05','CO','Lucknow',80);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into firstmcavalues('kavi','m','06','SPM','Dubai',86);
RESULT:
1 row created.
8/13/2019 cs2258 Dbms Record
5/93
5
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from firstmca;
OUTPUT:
STUNAME GENDER ROLLNO DEPTNAME ADDRESS PERCENT
Gokul M 01 DBMS Ooty 85
Mano M 02 AFM Mumbai 75
Kalai F 03 DS Chennai 70
Vengi M 04 PSP London 65
Sidu F 05 CO Lucknow 80
Kavi M 06 SPM Dubai 86
6 rows selected.
SYNTAX:
Select stuname from tablename;
EXAMPLE:
SQL> select stuname from firstmca;
RESULT:
6 rows selected.
STUNAME
Gokul
Mano
Kalai
Vengi
Sidu
kavi
8/13/2019 cs2258 Dbms Record
6/93
8/13/2019 cs2258 Dbms Record
7/93
7
SYNTAX:
Select min(percent) from tablename;
EXAMPLE:
SQL> select min(percent)from firstmca;
RESULT:
SYNTAX:
Select avg(percent) from tablename;
EXAMPLE:
SQL> select avg(percent)from firstmca;
OUTPUT:
SYNTAX:
Select stuname from tablename where percent>=80;
EXAMPLE:
SQL> select stuname from firstmca where percent>=80;
OUTPUT:
MIN(PERCENT)
65
AVG(PERCENT)
76.833333
STUNA
gokul
sidu
Kavi
8/13/2019 cs2258 Dbms Record
8/93
8
SYNTAX:
Altertabletablenamemodify(columnnamevarchar(6),columnamevarchar(6));
EXAMPLE:
SQL> alter table firstmcamodify(stunamevarchar(6),gender varchar(6));
OUTPUT:
Table altered.
SINGLE LINE FUNCTION
EXAMPLE:
selectSQL> select abs(-15)from dual;
OUTPUT:
EXAMPLE:
SQL> select power(5,2) from dual;
OUTPUT:
EXAMPLE:
SQL> select round(15.19,1)from dual;
ABS(-15)
15
POWER(5,2)
25
8/13/2019 cs2258 Dbms Record
9/93
9
OUTPUT:
EXAMPLE:
SQL> select sqrt(25) from dual;
OUTPUT:
EXAMPLE:
SQL> select ceil(14.33) from dual;
OUTPUT:
EXAMPLE:
SQL> select cos(90) from dual;
OUTPUT:
EXAMPLE:
SQL> select sin(180) from dual;
ROUND(15.19,1)
15.2
SQRT(25)
5
CEIL(14.33)
15
COS(90)
-.4480736
8/13/2019 cs2258 Dbms Record
10/93
10
OUTPUT:
EXAMPLE:
SQL> select exp(5) from dual;
OUTPUT:
EXAMPLE:
SQL> select mod(10,3) from dual;
OUTPUT:
EXAMPLE:
SQL> select lower('GOKUL') from dual;
OUTPUT:
LOWER
gokul
EXAMPLE:
SQL> select upper('gokul') from dual;
SIN(180)
-.8011526
EXP(5)
148.41316
MOD(10,3)
1
8/13/2019 cs2258 Dbms Record
11/93
11
OUTPUT:
EXAMPLE:
SQL> select length('gokul')from dual;
OUTPUT:
LENGTH('GOKUL')
5
EXAMPLE:
SQL> select ltrim('gokul','g') from dual;
OUTPUT:
LTRI
Okul
EXAMPLE:
SQL> select rtrim('gokul','l') from dual;
OUTPUT:
EXAMPLE:
SQL> select initcap('gokul') from dual;
UPPER
GOKUL
RTRI
Goku
8/13/2019 cs2258 Dbms Record
12/93
12
OUTPUT:
RESULT:
Thus the above program has been executed and verified successfully.
INITC
Gokul
8/13/2019 cs2258 Dbms Record
13/93
13
EXERCISE: 2(a)
DATE:25.09.2012 DATA MANIPULATION
AIM:
To create the data manipulation for
(a)Insert
Delete
Update
ALGORITHM:
Step 1:Start the program.
Step 2:Tables are crated and the values are inserted to table .
Step 3:Constrains was added to the field ticket no to the table.
Step 4:New column is added to the table and the table is displayed.
Step 5:Stop the program.
CODING:
The INSERT INTO statement
The INSERT INTO statement is used to insert a new row in a table.
SQL INSERT INTO Syntax
It is possible to write the INSERT INTO statement into two forms.
The first form doesnt specify the column names where the data will be
inserted only their values.
SYNTAX:
INSERT INTO table_nameVALUES(value1,value2,value3,);
8/13/2019 cs2258 Dbms Record
14/93
14
SQL INSERT INTO Example
SQL> INSERT INTO persons VALUES (5,kalai,akkash,rome 2,jeniva);
RESULT:
1 row created.
The DELETE Statement
The delete statement is used to delete rows in a table.
SQL DELETE syntax
Delete from table_name
Where some_column=some_value
EXAMPLE:
SQL>delete from persons Where last name =lkalai and first name=aakash;
RESULT:
1 row deleted.
EXAMPLE:
SQL>select * from pesons;
OUTPUT:
P_ID LASTE NAME FIRST NAME ADDRESSS CITY
4 Nilsson Johan Bracken 2 stavenger
1 Hansen Ola Timotevin Sandnes
2 Swenson Tove Brogan 23 Sandnes
3 Petersen Kari Storgt 20 Stavenger
5 Tjessem Jakob
DELETE All Rows
It is possible to delete all rows in a table without deleting the table. This means that the able
structure, attributes, and indexes will be intact.
8/13/2019 cs2258 Dbms Record
15/93
15
SYNTAX:
Delete from table_name;
Or
Delete * from table_name;
EXAMPLE:
SQL>select * from tab;
OUTPUT:
TNAME TABTYPE CLUSTERID
account table
bank tablediscounts table
doctor table
tiger table
EXAMPLE:
SQL>desc bank;
OUTPUT:
Name Null? Type
NAME VARCHAR2(10)
ACC_NO NUMBER(10)
AMMOUNT NUMBER(20)
EXAMPLE:
SQL>select * from discounts;
OUTPUT:
PRODNAME PRODPRICE PRODDISC
Diamonds 1000 10
Ruby 850 15
Sapphire 600 25
Emerald 2000 20
Topaz 400 30
8/13/2019 cs2258 Dbms Record
16/93
16
EXAMPLE:
SQL>delete discounts;
RESULT:
5 rows deleted.
EXAMPLE:
SQL>select * from discounts;
RESULT:
No rows selected.
The UPDATE statement
The update statement is used to update the existing records in a table.
SQL UPDATE Syntax
Update table_nameSet column1=value, column2=value2, Where come_column=some_value;
The where clause specified which record or records that should be updated. If you omit the where
clauses ,all records will be updated.
SQL UPDATE with WHERE clause example
EXAMPLE:
SQL>select * from persons;
OUTPUT:
P_ID LASTE NAME FIRST NAME ADDRESSS CITY
4 Nilsson Johan Bracken 2 stavenger
1 Hansen Ola Timotevin Sandnes
2 Swenson Tove Brogan 23 Sandnes
3 Petersen Kari Storgt 20 Stavenger
5 Tjessem Jakob
8/13/2019 cs2258 Dbms Record
17/93
17
EXAMPLE:
SQL>update persons
2 set address=nisstien67,city=Sandnes
3 where lastname=tjessem and first name=Jakob;
RESULT:
1 row updated.
EXAMPLE:
SQL>select * from persons;
OUTPUT:
P_ID LASTE NAME FIRST NAME ADDRESSS CITY
4 Nilsson Johan Bracken 2 stavenger
1 Hansen Ola Timotevin Sandnes
2 Swenson Tove Brogan 23 Sandnes
3 Petersen Kari Storgt 20 Stavenger
5 tjessem Jakob Nisstien 67 Sandnes
SQL update without where clause
EXAMPLE:
SQL>select * from tiger;
OUTPUT:
SNO NAME MARK
1 Vici 98
2 Parba 89
3 Jothi 79
3 Rain 67
4 Reshma 69
5 Giri 546 Joy 75
RESULT:
7 rows selected.
8/13/2019 cs2258 Dbms Record
18/93
18
EXAMPLE:
SQL>update tiger set sno=5,name=joy;
RESULT:
7 row updated .
EXAMPLE:
SQL>select * from tiger;
OUTPUT:
SNO NAME
5 Joy
5 Joy
5 Joy5 Joy
5 Joy
5 Joy
5 Joy
RESULT:
7 rows selected.
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
19/93
19
EXERCISE: 2(b)
DATE: 25.09.2012 DATA MANIPULATION
AIM:
To create the data manipulation for
(b) Select
Sub Query
Join
CODING:
The SQL SELECT Statement
The SELECT statement is used to select data from a database.
The result is stored in a result table , called the result-set.
SQL SELECT Syntax
SELECT column_list FROM table_name
[WHERE Clause]
[GROUP BY Clause]
[HAVING Clause]
[ORDER BY Clauses];
And
SYNTAX:
select*fromtable_name;
EXAMPLE:
SQL>select *from persons;
8/13/2019 cs2258 Dbms Record
20/93
20
OUTPUT:
P_ID LAST NAME FIRST NAME ADDRESS CITY
4 Nelson Johan Bakken2 Stavanger
1 Hansen Ola Timotevin Sandnes
2 Svendson Tove Borgvn 23 Sandnes3 Pettersen Kari Storgt 20 Stavenger
5 Tjessem Jakob
6 Kalai Aakash Rome2 jeniva
RESULT:
6 rows selected.
The SQL SELECT DISTINCT statement
In a table, some of the columns may contain duplicate values. This is not a problem however
sometimes you will want to list only the different values in a table
The distinct keyword can be used to return only different values.
SQL SELECT DISTINCT
SYNTAX:
select distinctcolumn_namefromtable_name;
EXAMPLE:
Sql>select * from persons;
OUTPUT:
P_ID LASTE NAME FIRST NAME ADDRESS CITY
4 Nilsen Johan Bakken 2 Stavanger
1 Hansen Ola Timotevin Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 pettersen Kari Storgt 20 Stavenger
5 Tjessen Jakob
6 kalai Aakash Rome2 jeniva
RESULT:
6 rows selected
8/13/2019 cs2258 Dbms Record
21/93
21
EXAMPLE:
SQL>select distinct city from persons;
OUTPUT:
City
Stavanger
Sandnes
Stavenger
Jeniva
The WHERE Clause
The where clauses is used to extract only those records that fulfill a specified criterion.
SQL WHERE
SYNTAX:
Select column_name from table_name where column_name operator value;
WHERE clause
EXAMPLE:
SQL> select * from persons where city=sandnes;
OUTPUT:
P_ID LASTE NAME FIRST NAME ADDRESS CITY
1 Hansen Ola Timotevin Sandnes
2 Svendson Tove Borgvn 23 Sandnes
JOINS
EXAMPLE:
SQL> create table p1(pid number(5),pnamevarchar(20),snamevarchar(15),unitprice number(5));
8/13/2019 cs2258 Dbms Record
22/93
22
RESULT:
Table created.
EXAMPLE:
SQL> insert into p1 values(100,'camera','nikon',300);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into p1 values(101,'tv','onida',100);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into p1 values(102,'fridge','vediocon',150);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into p1 values(103,'ipod','apple',75);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into p1 values(104,'mobile','nokia',50);
RESULT:
1 row created.
EXAMPLE:
SQL> select * from p1 ;
8/13/2019 cs2258 Dbms Record
23/93
23
OUTPUT:
PID PNAME SNAME UNITPRICE
100 Camera Nikon 300
101 Tv onida 100
102 Fridge Videocon 150
103 Ipod Apple 75
104 Mobile Nokia 50
EXAMPLE:
SQL> create table ordritems(odrid number(5),pid number(5),totalunits number(3),customer varchar(10));
RESULT:
Table created.
EXAMPLE:
SQL> insert into ordritemsvalues(5100,104,30,'infosys');
RESULT:
1 row created.
EXAMPLE:
SQL> insert into ordritemsvalues(5101,102,5,'satyam');
RESULT:
1 row created.
EXAMPLE:
SQL> insert into ordritemsvalues(5102,103,25,'wipro');
RESULT:
1 row created.
EXAMPLE:
SQL> insert into ordritems values(5103,101,10,'tcs');
8/13/2019 cs2258 Dbms Record
24/93
24
RESULT:
1 row created.
EXAMPLE:
SQL> select * from ordritems;
OUTPUT:
ORDID PID TOTALUNITS CUSTOMER
5100 104 30 Infosys
5101 102 5 Satyam
5102 103 25 Wipro
5103 101 10 Tcs
EXAMPLE:
SQL> select odrid,pname,unitprice,sname,totalunits from p1,ordritems where ordritems.pid=p1.pid;
OUTPUT:
ORDID PNAME UNITPRICE SNAME TOTALUNITS
5103 tv 100 onida 10
5101 fridge 150 videocon 5
5102 ipod 75 apple 25
5100 mobile 50 nokia 30
LEFT OUTER JOIN
EXAMPLE:
SQL> select p1.pid,p1.pname,ordritems.odrid,ordritems.totalunits from ordritems,p1 where
ordritems.pid(+)=p1.pid;
OUTPUT:
PID PNAME ORDID TOTALUNITS
100 Camera
101 Tv 5103 10
102 Fridge 5101 5
103 Ipod 5102 25
104 Mobile 5100 30
8/13/2019 cs2258 Dbms Record
25/93
25
RIGHT OUTER JOIN
EXAMPLE:
SQL> select p1.pid,p1.pname,ordritems.odrid,ordritems.totalunits from ordritems,p1 where
ordritems.pid=p1.pid(+);
OUTPUT:
PID PNAME ORDID TOTALUNITS
101 Tv 5103 10
102 Fridge 5101 5
103 Ipod 5102 25
104 Mobile 5100 30
NON EQUI JOIN
EXAMPLE:
SQL> select pid,pname,sname from p1 where sname!='nokia';
OUTPUT:
PID PNAME SNAME
100 Camera Nikon
101 Tv Onida
102 Fridge Videocon
103 Ipod Apple
EXAMPLE:
SQL> select pid,pname,sname from p1 where sname='nokia';
OUTPUT:
PID PNAME SNAME
104 Mobile Nokia
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
26/93
26
EXERCISE: 3
DATE:09.10.2012 DATA CONTROL COMMAND
AIM:
To create a program using queries function.
ALGORITHM:
Step1:Start the process.
Step2:To view the table using select query.
Step3:Select the table for getting the maximum ticket no from the table using sub queries.
Step4:View the ticket from the ticket header.
Step5:Stop the process.
CODING:
SYNTAX:
Create table tablename(variable datatype(size));
EXAMPLE:
SQL> create table ch(catcode number(10));
RESULT:
Table created.
SYNTAX:
Insert into tablenamevalues(&variable);
EXAMPLE:
SQL> insert into chvalues(&catcode);
8/13/2019 cs2258 Dbms Record
27/93
27
RESULT:
Enter value for catcode: 40
old 1: insert into ch values(&catcode)
new 1: insert into ch values(40)
1 row created.
SYNTAX:
Select * from table name;
EXAMPLE:
SQL> select * from ch;
OUTPUT:
CATCODE
40
SYNTAX:
Create table tablename(column_name1 datatype, column_name2 datatype, column_name3 datatype,
column_name4 datatype,column_name5 datatype, column_name6 datatype);
EXAMPLE:
SQL> create table rh(routeid number(5),catcode number(5),origin varchar(10),destination
varchar(10),distance_kms number(10),fare number(5));
RESULT:
Table created.
SYNTAX:
insert into tablename values(value_1, value_2, value_3, value_4, value_5, value_6);
EXAMPLE:
SQL> insert into rhvalues(&routeid,&catcode,'&origin','&destination',&distance_kms,&fare);
8/13/2019 cs2258 Dbms Record
28/93
28
RESULT:
Enter value for routeid: 1
Enter value for catcode: 40
Enter value for origin: erode
Enter value for destination: salem
Enter value for distance_kms: 70
Enter value for fare: 50
old 1: insert into rh values(&routeid,&catcode,'&origin','&destination',&distance_kms,&fare)
new 1: insert into rh values(1,40,'erode','salem',70,50)
1 row created.
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from rh;
OUTPUT:
SYNTAX:
Create table tablename(column_name1 datatype,column_name2 datatype);
EXAMPLE:
SQL> create table ph(place_id number(10),busstationvarchar(10));
RESULT:
Table created.
ROUTEID CATCODE ORIGIN DESTINATION DISTANCE_KMS FARE
1 40 erode salem 70 50
8/13/2019 cs2258 Dbms Record
29/93
29
SYNTAX:
Insert into tablenamevalues(value_1,value_2);
EXAMPLE:
SQL> insert into phvalues(&place_id,'&busstation');
RESULT:
Enter value for place_id: 1
Enter value for busstation: Erode
old 1: insert into ph values(&place_id,'&busstation')
new 1: insert into ph values(1,'Erode')
1 row created.
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from ph;
OUTPUT:
SYNTAX:
Create table tablename(column_name1 datatype, column_name2 datatype, column_name3 datatype);
EXAMPLE:
SQL> create table rd(route_id number(10),place_id number(10),day varchar(10));
RESULT:
Table created.
PLACE_ID BUSSTATION
1 Erode
8/13/2019 cs2258 Dbms Record
30/93
30
SYNTAX:
Insert into tablenamevalues(value_1,value_2,vale_3);
EXAMPLE:
SQL> insert into rdvalues(&route_id,&place_id,'&day');
RESULT:
Enter value for route_id: 1
Enter value for place_id: 101
Enter value for day: monday
old 1: insert into rd values(&route_id,&place_id,'&day')
new 1: insert into rd values(1,101,'monday')
1 row created.
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from rd;
OUTPUT:
ROUTE_ID PLACE_ID DAY
1 101 Monday
SYNTAX:
Create table tablename(column_name1 datatype,column_name2 datatype);
EXAMPLE:
SQL> create table th(ticketno number(10),no_of_tickets number(10));
RESULT:
Table created.
8/13/2019 cs2258 Dbms Record
31/93
31
SYNTAX:
Insert into tablenamevalues(value_1,value_2);
EXAMPLE:
SQL> insert into thvalues(&ticket,&no_of_tickets);
RESULT:
Enter value for ticket: 1
Enter value for no_of_tickets: 5
old 1: insert into th values(&ticket,&no_of_tickets)
new 1: insert into th values(1,5)
1 row created.
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from th;
OUTPUT:
SYNTAX:
Create table tablename(column_name1 datatype, column_name2 datatype, column_name3 datatype,
column_name4 datatype, column_name5 datatype, column_name6 datatype);
EXAMPLE:
SQL> create table td(ticketno number(10),passenger_namevarchar(10),gender varchar(10),age
number(10),seat_no number(10),amt number(10));
RESULT:
Table created.
TICKETNO NO_OF_TICKETS
1 5
8/13/2019 cs2258 Dbms Record
32/93
32
SYNTAX:
Insert into tablenamevalues(value_1, value_2, value_3, value_4, value_5, value_6);
EXAMPLE:
SQL> insert into td values(&ticketno,'&passenger_name','&gender',&age,&seat_no,&amt);
RESULT:
Enter value for ticketno: 1
Enter value for passenger_name: gokul
Enter value for gender: male
Enter value for age: 22
Enter value for seat_no: 5
Enter value for amt: 50
old 1: insert into td values(&ticketno,'&passenger_name','&gender',&age,&seat_no,&amt)
new 1: insert into td values(1,'gokul','male',22,5,50)
1 row created.
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from td;
OUTPUT:
TICKETNO PASSENGER_NAME GENDER AGE SEAT_NO AMT
1 gokul male 22 5 50
SYNTAX:
Select * from tablename where origin=value and destination=value;
EXAMPLE:
SQL> select * from rh where origin='chennai' and destination='coimbatore';
8/13/2019 cs2258 Dbms Record
33/93
33
OUTPUT:
SYNTAX:
Select distinct columnname from tablename order by columnnamedesc;
EXAMPLE:
SQL> select distinct catcode from rh order by catcodedesc;
OUTPUT:
SYNTAX:
Select * from tablename;
EXAMPLE:
SQL> select * from rh;
OUTPUT:
ROUTEID CATCODE ORIGIN DESTINATION DISTANCE_KMS FARE
3 60 chennai Coimbatore 75 200
CATCODE
40
50
60
ROUTEID CATCODE ORIGIN DESTINATIO DISTANCE_KMS FARE
1 40 erode salem 70 50
2 50 chennai salem 80 100
3 60 chennai coimbatore 75 200
8/13/2019 cs2258 Dbms Record
34/93
34
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
35/93
35
EXERCISE: 4
DATE: 16.10.2012 HIGH LEVEL LANGUAGES EXTENSION-PL/SQL or
TRANSACT SQL
AIM:
Display the row from table details and route details with greater than of table header and route
header in the ticket number.
ALGORITHM:
Step1:Start the process.
Step2:All rows are displayed by subquires from the table.
Step3:View table is displayed.
Step4:Create a ticket number, tables and if it display by using quries.
Step5:Stop the process.
CODING:
EXAMPLE:
SQL> select * from td where ticketno>any(select ticketno from th);
OUTPUT:
EXAMPLE:
SQL> select * from rh where rout_id>all(select rout_id from rd where place_id=100);
OUTPUT:
ROUT_ID CATCODE ORIGIN DESTINATION DISTANCE_KMS
001 20 madras erode 200
TICK PASS_NAME GENDER AGE SEATNO AMOUNT
401 arun MALE 21 44 100
8/13/2019 cs2258 Dbms Record
36/93
36
EXAMPLE:
SQL> create view tke as select a.ticketno,b.origin,destination,rout_id from tha,rh b;
OUTPUT:
View created.
EXAMPLE:
SQL> select* from tke;
OUTPUT:
TICK_NO ORIGIN DESTINATION ROUT_ID
301 madras Erode 001
RESULT:
Thus the above program was compiled and executed successfully.
8/13/2019 cs2258 Dbms Record
37/93
37
EXERCISE: 5
DATE: 15.11.2012 USE OF CURSORS, PROCEDURES AND FUNCTIONS
AIM:
To create a function, cursor and procedures for using pl/sql queries.
ALGORITHM:
Step1:Start the process.
Step2:Use function to declare the variable.
Step 3:Create the cursor to find the balance amount will greater than 300 in the table.
Step4:Create a new table account and insert the value.
Step5:By using the balance >2500.
Step6:Stop the process.
CODING:
FUNCTION CREATION:
SQL> create or replace function large(a number,bnumber,c number)return number is large
number(3);
2 begin
3 large:=a;
4 if(large
8/13/2019 cs2258 Dbms Record
38/93
38
11 end;
12 /
RESULT:
Function created.
FUNCTION DECLARATION:
SQL> declare
2 a number(3);
3 b number(3);
4 c number(3);
5 d number(3);
6 begin
7 a:=&n1;
8 b:=&n2;
9 c:=&n3;
10 d:=large(a,b,c);
11 dbms_output.put_line('large no is '||d);
12 end;
13 /
RESULT:
Enter value for n1: 5
old 7: a:=&n1;
new 7: a:=5;
Enter value for n2: 3
old 8: b:=&n2;
8/13/2019 cs2258 Dbms Record
39/93
39
new 8: b:=3;
Enter value for n3: 6
old 9: c:=&n3;
new 9: c:=6;
large no is 5
RESULT:
PL/SQL procedure successfully completed.
TABLE CREATION:
SQL> create table account11(acc_idvarchar(20),name varchar(20),balance number(5));
RESULT:
Table created.
EXAMPLE:
SQL>insert into account11 values('&acc_id','& name','& balance');
Enter value for acc_id: a101
Enter value for name: siddhu
Enter value for balance: 50000
old 1: insert into account11 values('&acc_id','& name','& balance')
new 1: insert into account11 values('a101','siddhu','50000')
RESULT:
1 row created.
EXAMPLE:
SQL>insert into account11 values('&acc_id','& name','& balance');
Enter value for acc_id: a102
Enter value for name: sumi
Enter value for balance: 25000
8/13/2019 cs2258 Dbms Record
40/93
40
old 1: insert into account11 values('&acc_id','& name','& balance')
new 1: insert into account11 values('a102','sumi','25000')
RESULT:
1 row created.
EXAMPLE:
SQL>insert into account11 values('&acc_id','& name','& balance');
Enter value for acc_id: a103
Enter value for name: arul
Enter value for balance: 15000
old 1: insert into account11 values('&acc_id','& name','& balance')
new 1: insert into account11 values('a103','arul','15000')
RESULT:
1 row created.
IMPLICIT CURSOR:
SQL>declare
2 cursor c123 is select acc_id,name,balance from acc11 where balance>300;
3 a acc11.acc_id %type;
4 n acc11.name%type;
5 b acc11.balance%type;
6 begin
7 open c123;
8 loop
9 fetch c123 into a,n,b;
8/13/2019 cs2258 Dbms Record
41/93
41
10 exist when c123% not found;
11 dbms-output.put-line('account-id'||a);
12 dbms-output.put-line('name:'||n);
13 dbms-output.put-line('balance:'||b);
14 end loop;
15 close c123;
16 end;
17 /
RESULT:
account-ida101
name:siddhu
balance:50000
PL/SQL procedure successfully completed.
EXPLICIT CURSOR:
SQL>declare
2 cursor c124 is select * from acc11;
3 id varchar2(14);
4 x c124 % rowtype;
5 begin
6 open c124;
7 id:= '&acc_id';
8 loop
9 fetch c124 into x;
10 exit when(id=x.acc_id);
11 end loop;
8/13/2019 cs2258 Dbms Record
42/93
42
12 update acc11 set balance=balance+(balance * 0.02)where acc_id=id and balance>300;
13close c124;
14end;
15 Enter value for acc_id:102
16 Old 7:id:='&acc_id';
17 New 7:id:='102';
RESULT:
PL/SQL procedure successfully completed.
RESULT:
Thus the above program was compiled and executed successfully.
8/13/2019 cs2258 Dbms Record
43/93
43
EXERCISE: 6
DATE: 15.11.2012 EMBEDDED SQL OR DATABASE CONNECTIVITY
AIM:
To create a database using a embedded sql or database connectivity.
ALGORITHM:
Step1:Start the process.
Step2:Create the table and enter the values for sub queries.
Step 3: Select the particular values by using the sub queries.
Step4:Connect the two columns of one table and view as on in another table.
Step5:View the table of two table if the values of two column are same.
Step6:Stop the process.
CODING:
Example:
SQL> create table studdetail(id number(30),firstnamevarchar(20),last varchar(20),age
number(20),subject varchar(2),games varchar(20));
RESULT:
Table created.
EXAMPLE:
SQL> insert into studdetailvalues('&acc_id','&firstname','&lastname','&age','&subject','&games')
Enter value for acc_id: 100
Enter value for firstname: siddhu
Enter value for lastname: prasath
Enter value for age: 20
8/13/2019 cs2258 Dbms Record
44/93
44
Enter value for subject: ss
Enter value for games: cricket
old 1: insert into studdetail values('& acc_id','&firstname','&lastname','&age','&subject','&game
new 1: insert into studdetail values('100','siddhu','prasath','20','ss','cricket')
RESULT:
1 row created.
Example:
SQL> insert into studdetailvalues('&acc_id','&firstname','&lastname','&age','&subject','&games')
Enter value for acc_id: 200
Enter value for firstname: sumi
Enter value for lastname: sampath
Enter value for age: 21
Enter value for subject: sc
Enter value for games: hockey
old 1: insert into studdetail values('&acc_id','&firstname','&lastname',
'&age','&subject','&games);
new 1: insert into studdetail values('200','sumi','sampath','21','sc','hockey')
RESULT:
1 row created.
Example:
SQL> insert into studdetailvalues('& acc_id','&firstname','&lastname',
'&age','&subject','&games');
Enter value for acc_id: 300
Enter value for firstname: sudhiksha
Enter value for lastname: nandhu
8/13/2019 cs2258 Dbms Record
45/93
45
Enter value for age: 18
Enter value for subject: tt
Enter value for games: tenis
old1: insert into studdetailvalues('& acc_id','&firstname',
'&lastname','&age','&subject','&games
new 1: insert into studdetail values('300','sudhiksha','nandhu','18','tt','tenis')
RESULT:
1 row created.
EXAMPLE:
SQL> select *from studdetail;
OUTPUT:
SUB QUERIES
EXAMPLE:
SQL> select id,firstname from studdetail where firstname in (select firstname from studdetail wh
su='ss');
OUTPUT:
ID FIRSTNAME
100 siddhu
EXAMPLE:
SQL> create table mathsgroup13(id number(5),name varchar(20));
ID FIRSTNAME LAST AGE SU GAMES
100 siddhu prasath 20 ss cricket
200 sumi sampath 21 sc hockey
300 sudhiksha nandhu 18 tttenis
8/13/2019 cs2258 Dbms Record
46/93
46
RESULT:
Table created.
EXAMPLE:
SQL> insert into mathsgroup13 values(400,'arul');
RESULT:
1 row created.
EXAMPLE:
SQL> insert into mathsgroup13 values(500,'sindhu');
RESULT:
1 row created.
EXAMPLE:
SQL> select *from mathsgroup13;
OUTPUT:
EXAMPLE:
SQL> select *from studdetail where age>=(select avg(age)from studdetail);
OUTPUT:
ID FIRSTNAME LAST NMAE AGE GAMES
400 arul prasath 27 football
EXAMPLE:
SQL> create table product (product number (4), productnamevarchar (10), suppliernamevarchar
(10), unitprice number (10));
RESULT:
Table created.
EXAMPLE:
SQL> insert into product values(100,'camera','canon',7000);
ID NAME
400 arul
500 sindhu
8/13/2019 cs2258 Dbms Record
47/93
47
RESULT:
1 row created.
EXAMPLE:
SQL> insert into product values(200,'ipod','apple',18000);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into product values(300,'ac','bluestar',30000);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into product values(400,'fridge','samsung',20000);
RESULT:
1 row created.
EXAMPLE:
SQL> select *from product;
OUTPUT:
PRODUCTID PRODUCTNAME SUPPLIERNAME UNITPRICE
100 Camera Canon 7000
200 Ipod Apple 18000
300 Ac Bluestar 30000
400 Fridge Samsung 20000
EXAMPLE:
SQL> create table orderitem(ordered number(10),productid number(10),totalunits
number(10),customer varchar(10));
RESULT:
Table created.
8/13/2019 cs2258 Dbms Record
48/93
48
EXAMPLE:
SQL> insert into orderitemvalues(2000,100,40,'wipro');
RESULT:
1 row created.
EXAMPLE:
SQL> insert into orderitemvalues(3000,200,50,'infosys');
RESULT:
1 row created.
SYNTAX:
SQL> insert into orderitemvalues(4000,300,60,'hcl');
RESULT:
1 row created.
RESULT:
SQL> select *from orderitem;
OUTPUT:
ORDERID PRODUCTID TOTALUNITS CUSTOMER2000 100 40 Wipro
3000 200 50 Infosys
4000 300 60 HCL
SYNTAX:
SQL> select orderid,productname,unitprice,suppliername,totalunits from product,orderitem wher
orderitem.productid=product.productid;
OUTPUT:
ORDERID PRODUCTNAME UNITPRICE SUPPLIER TOTALUNITS
2000 camera 7000 canon 40
3000 ipod 18000 apple 50
4000 ac 30000 bluestar 60
8/13/2019 cs2258 Dbms Record
49/93
49
SYNTAX:
SQL>select orderid,product.productname,product.unitprice,product.supplier.order.
Totalunitsfrom product.product,orderitem.order where order.productid=p.productid;
OUTPUT:
ORDERID PRODUCTNAME UNITPRICE SUPPLIER TOTALUNITS
2000 camera 7000 canon 40
3000 ipod 18000 apple 50
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
50/93
50
EXERCISE: 7
DATE:22.11.2012 ORACLE OR SQL SERVER TRIGGERS
AIM:
To create a program using transaction control language and data control command.
ALGORITHM:
Step1:Start the program.
Step2:Using transaction control language commit,rollback,savepoint.
Step3:Commit is used to save the changes.
Step4:Rollback can be used to restore the values.
Step5:Savepoint is used to save the values.
Step6:By using data control commands such as grant revoke we can be grant the permission.
Step7:Stop the program.
CODING:
SYNTAX:
SQL> create table gokul(name varchar(10),balance number(10));
RESULT:
Table created.
EXAMPLE:
SQL> insert into gokulvalues('elango',1500);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into gokulvalues('durai',1200);
8/13/2019 cs2258 Dbms Record
51/93
51
RESULT:
1 row created.
EXAMPLE:
SQL> insert into gokulvalues('gowri',1900);
RESULT:
1 row created.
EXAMPLE:
SQL> insert into gokulvalues('inba',2500);
RESULT:
1 row created.
EXAMPLE:
SQL> select * from gokul;
OUTPUT:
NAME BALANCE
Elango 1500
Durai 1200
Gowri 1900
Inba 2500
PROGRAM 1:
SQL> set serveroutput on;
SQL> create or replace trigger trg1 before update or insert or delete on gokul
2 for each row
3 begin
4 if updating then
8/13/2019 cs2258 Dbms Record
52/93
52
5 dbms_output.put_line('updating');
6 elsif inserting then
7 dbms_output.put_line('inserting');
8 elsif deleting then
9 dbms_output.put_line('deleting');
10 end if;
11 end;
12 /
OUTPUT:
Trigger created.
PROGRAM 2:
SQL> create or replace trigger trg2
2 before update on gokul
3 for each row
4 begin
5 if:new_balance
8/13/2019 cs2258 Dbms Record
53/93
53
PROGRAM 3:
SQL> create trigger trg3 after insert on t4 referencing new as newrows for each row
when(newrows.balance=1800)
2 begin
3 insert into t5 values(:newrows.balance=1800)
4 begin
5 insert into t5 values(:newrows.b1:newrows.a)
6 end trg3;
7 /
EXAMPLE:
SQL>Create table I(a number(20), b varchar(25));
RESULT:
Table created
EXAMPLE:
SQL> create table s (b varchar(20), a number(25));
RESULT:
Table created
Trigger created
EXAMPLE:
SQL> insert into I values(10,cool);
RESULT:
One row created
EXAMPLE:
Select * from s;
8/13/2019 cs2258 Dbms Record
54/93
54
OUTPUT:
B A
COOL 10
PROGRAM 4:
SQL> trigger to delete the account details when customer gets deleted
SQL> create or replace trigger trg4
After delete on table name
For each row
Begin
Delete from table name when table name. column name;
End;
SYNTAX:
SQL> create table a1(name varchar2(20),custid number(30));
RESULT:
Table created.
EXAMPLE:
create table b1(name varchar2(20),custid number(30));
RESULT:
Table created.
Insert into a1(&name,&custid);
Insert into name:Gokul
Insert into custid:08
OUTPUT:
Trigger created.
8/13/2019 cs2258 Dbms Record
55/93
55
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
56/93
56
EXERCISE: 8
DATE:27.11.2012 WORKING WITH FORMS
AIM:
To write a program in vb.net for creating a forms for arithmetic operation.
ALGORITHM:
Step1: Start the process.
Step2:Create a form in vb.
Step3:Place five command buttons, give the name for command button.
Step4:Display code page by clicking the button.
Step5:Enter the code for corresponding buttons as given below.
Step6:Execute the program by clicking run in the menu.
Step7:Stop the process.
CODING:
ADDITION:
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
SUBTRACTION:
Private Sub Command2_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub
8/13/2019 cs2258 Dbms Record
57/93
57
MULTIPLICATION:
Private Sub Command3_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
DIVISION:
Private Sub Command4_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub
EXIT:
Private Sub Command5_Click()
End
End Sub
MENU DESIGN:
BLUE:
Privite sub mblue_click()
Form1.backcolor=vbblue
End sub
GREEN:
Privite sub mgreen_click()
Form1.backcolor=vbgreen
End sub
8/13/2019 cs2258 Dbms Record
58/93
58
RED:
Privite sub mred_click()
Form1.backcolor=vbred
End sub
EXIT:
Privite sub exit_click()
end
End sub
FORM CONNECTIVITY:
(i) Connection from form1 to form2.
8/13/2019 cs2258 Dbms Record
59/93
59
FORM DESIGN:
(ii) Sample Input is given below.
(iii) Then enter the values in text box1 and textbox2.(iv) And click on add command button.(v) The result will be displayed in the result text box.(vi) Likewise for subtraction,multiplication and division.(vii) Finally click on exit command button.
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
60/93
60
EXERCISE: 9(a)
DATE:02.12.2012 WORKING WITH MENU
AIM:
To create a program in vb for creating a menu design.
ALGORITHM:
Step1:Start the process.
Step2:Create a form in vb.
Step3: Select menu->tools->menu editor ->caption enter &file and &Edit.
Step4:&File is the main menu item that lists save,new,minimize,exit when u click on the File option.
Step5:In caption enter save,new,minimize,exit and click right arrow ,these details to be entered and
Dislayedbelow file option.
Step6:In menu->tools->menu editor ->short cut enter ctrl+s ,ctrl+n for short options.
Step7:Incaption enter edit,cut,copy,paste and click right arrow ,these details to be entered
anddislayedbelow edit option.
Step8:In menu->tools->menu editor ->short cut enter ctrl+ e,ctrl+x, ctrl+c, ctrl+v for shortcut
Step9:Code to be written for (file->save,new,minimize,exit and edit->edit,cut,copy,paste) double click onthese particulars to write code for these to perform its operation.
Step10:Execute the program by double clicking run button in the menu
Step11:Stop the process.
CODING:
COPY:
Private Sub menucopy_Click()
Clipboard.Clear
8/13/2019 cs2258 Dbms Record
61/93
61
Clipboard.SetText Text1.SelText
End Sub
CUT:
Private Sub menucut_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
Text1.SelText = ""
End Sub
EXIT:
Private Sub menuexit_Click()
End
End Sub
MINIMIZE:
Private Sub menuminimize_Click()
Form1.WindowState = 1
End Sub
NEW:
Private Sub menunew_Click()
Text1.Text = ""
End Sub
PASTE:
Private Sub menupaste_Click()
Text1.SelText = Clipboard.GetText()
End Sub
8/13/2019 cs2258 Dbms Record
62/93
62
SAVE:
Private Sub menusave_Click()
commondialog1.Filter = "all files(*.*)|*.*|text files(*.txt)|*.txt"
CommonDialog1.ShowSave
Dim ifile As Integer
ifile = FreeFile
Open commondialod1.FileName For Output As #file
Print #ifile, Text1.Text
End Sub
FORM 1:
Empty input form.
8/13/2019 cs2258 Dbms Record
63/93
63
FORM 2:
Input form with MENU values.
FORM 3:
Form for arrow indication.
8/13/2019 cs2258 Dbms Record
64/93
64
FORM 4:
Form with list values with their shortcut keys.
FORM 5:
Form with list value SAVE.
8/13/2019 cs2258 Dbms Record
65/93
65
FORM 6:
Form with main menu EDIT.
FORM 7:
Form with list value CUT.
8/13/2019 cs2258 Dbms Record
66/93
66
FORM 8:
Form with common dialoguebox and multivaluepropertie as TRUE.
FORM 9:
Form with scroll propertie as 3-bothfor scrolling the common dialogue box as up and down as
well right and left..
8/13/2019 cs2258 Dbms Record
67/93
67
FORM 10:
In the component dialogue box enable the MICROSOFT COMMON DIALOG CONTROL 6.0(SP3)
FORM 11:
In this form click on file->new to enter the sentence or a paragraph.
8/13/2019 cs2258 Dbms Record
68/93
68
FORM 12:
After enter into that box, click on save option from file menu to save that sentence.
FORM 13:
In this form, we can perform copy the sentence from that box.
8/13/2019 cs2258 Dbms Record
69/93
69
FORM 14:
After the sentence is copied, we can perform paste option from the edit menu.
FORM 15:
Now that selected sentence is pasted in that text box.
8/13/2019 cs2258 Dbms Record
70/93
70
FORM 16:
In this form, we can cut the required words from that sentence.
FORM 17:
The required word can be cut frim that text box.
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
71/93
71
EXERCISE: 9(b)
DATE:02.12.2012 WORKING WITH REPORTS
AIM:
To create a program in vb for creating a student report.
ALGORITHM:
Step1:Start the process.
Step2:Create a table in oracle.
Step3:Create a form in vb.
Step4:Place five buttons ,double click on each to write code to perform the desired opearttion.
Step5:Execute the program by double clicking run button in the menu ,click add new button and enter det
and click save button the details entered is updated in the table.
Step6:Display values in the oracle
Step7: Right click->components->[controls->Microsoft datacontrol 6.0(SP4)(OLEDB),designers->data
environment ,data control]click ok
Step8:A picture for adodc will appear in the tool box->right click->adodc properties->3rdoption->build
->authentication->record source->select the name of the table created in oracle.
Step9: Click project explorer->form1->right click->add->data environment->a dialogue box appear->data
environment1_connection1->right click->Microsoft oledb provider for oracle->click ok
Step10:Click project explorer->form1->right click->add->data environment->a dialogue box appear->dat
environment1_connection1->right click->add command->command1 will be appear after
connection1->right click on command1->properties->data base object->dropdown list
select(TABLE)->In object name provide user name, password->your table will appear->select the
table name.
Step11:Click project explorer->form1->right click->add->data environment->a dialogue box appear->data report->report1 dialogue box will appear
Step12:Drag command1 from project environment to data report execute the program by double clicking
run button in the menu click report button, a report for student will be generated
Step13:Stop the process.
8/13/2019 cs2258 Dbms Record
72/93
72
SYNTAX:
SQL> create table gokul(Name varchar(10),RollNo number(10));
RESULT:
Table created.
CODING:
ADD NEW:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub
SAVE:
Private Sub Command2_Click()
Adodc1.Recordset.Save
End Sub
DELETE:
Private Sub Command3_Click()
Adodc1.Recordset.Delete
End Sub
UPDATE:
Private Sub Command4_Click()
Adodc1.Recordset.Update
End Sub
8/13/2019 cs2258 Dbms Record
73/93
73
REPORT:
Private Sub Command5_Click()
DataReport1.Show
End Sub
END
Private Sub Form_Load()
End Sub
FORM1:
Sample input form
8/13/2019 cs2258 Dbms Record
74/93
74
FORM 2:
Form for ADODC properties.
FORM 3:
Form for selection of data environment,data report.
8/13/2019 cs2258 Dbms Record
75/93
75
FORM 4;
Form that shows the ADODC properties.
FORM 5:
Establishilng connection from database.
8/13/2019 cs2258 Dbms Record
76/93
8/13/2019 cs2258 Dbms Record
77/93
77
FORM 8:
Properties set to ADODC1 for datasource as object.
FORM 9:
Set the datafield in properties as name for textbox1 and same as for that rollno for textbox2.
8/13/2019 cs2258 Dbms Record
78/93
78
FORM 10:
Here we can enter the name and rollno in that text box.
EXAMPLE:
SQL> select * from gokul;
RESULT:
NAME ROLLNO
Hari 12
8/13/2019 cs2258 Dbms Record
79/93
79
FORM 11:
DataEnvironment is made enabled.
FORM 12:
Set properties for command1.
8/13/2019 cs2258 Dbms Record
80/93
80
FORM 13:
Enable the database connection for report.
FORM 14:
Add the command from command1 properties.
8/13/2019 cs2258 Dbms Record
81/93
81
FORM 15:
Set the command properties for command.
FORM 16:
Select the table name and for their connection for datareport.
8/13/2019 cs2258 Dbms Record
82/93
82
FORM 17:
Select the table name as given in database.
FORM 18:
Select the data report from the properties.
8/13/2019 cs2258 Dbms Record
83/93
83
FORM 19:
Data report form is now generated.
FORM 20:
In the properties dialog box select datamember as command1.
8/13/2019 cs2258 Dbms Record
84/93
84
FORM 21:
On compilation for generality reporting, security is provided.
FORM 22:
Reporrt form is now generated.
8/13/2019 cs2258 Dbms Record
85/93
85
FORM 23:
Output for the report is given below.
RESULT:
Thus the above program has been executed and verified successfully.
8/13/2019 cs2258 Dbms Record
86/93
86
EXERCISE: 10
DATE:02.12.2012 FRONT END TOOLS
AIM:
To create a program in vb for creating a bank report generation.
ALGORITHM:
Step1:Start the process.
Step2: Create a table in oracle.
Step3: Create a form in vb.
Step4: Place eleven buttons; double click on each to write code to perform the desired operation.
Step5:Execute the program by double clicking run button in the menu ,click add button and enter details
click save button the details entered is updated in the table.
Step6:Display values in the oracle
Step7:Right click->components->[controls->Microsoft data control 6.0(SP4)(OLEDB),designers->data
environment ,data control]click ok
Step8:A picture for adodc will appear in the tool box->right click->adodc properties->3rdoption->build
->authentication->record source->select the name of the table created in oracle.
Step9:Click project explorer->form1->right click->add->data environment->a dialogue box appear->data
environment1_connection1->right click->Microsoft oledb provider for oracle->click ok
Step10:Click project explorer->form1->right click->add->data environment->a dialogue box appear->da
environment1_connection1->right click->add command->command1 will be appear after
connection1->right click on command1->properties->data base object->dropdown list
select(TABLE)->In object name provide user name, password->your table will appear->select the
table name.
Step11:Click project explorer->form1->right click->add->data environment->a dialogue box appear- >data report->report1 dialogue box will appear
Step12:Drag command1 from project environment to data report execute the program by double clicking
run button in the menu click report button, report for bank report will be generated
Step13:Stop the process.
8/13/2019 cs2258 Dbms Record
87/93
87
CODING:
ADD NEW:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub
REPORT:
Private Sub Command10_Click()
DataReport1.Show
End Sub
END:
Private Sub Command11_Click()
End
End Sub
MOVEFIRST:
Private Sub Command2_Click()
Adodc1.Recordset.MoveFirst
End Sub
MOVENEXT:
Private Sub Command3_Click()
Adodc1.Recordset.MoveNext
End Sub
SAVE:
Private Sub Command4_Click()
Adodc1.Recordset.Save
End Sub
8/13/2019 cs2258 Dbms Record
88/93
88
UPDATE:
Private Sub Command5_Click()
Adodc1.Recordset.Update
End Sub
MOVELAST:
Private Sub Command6_Click()
Adodc1.Recordset.MoveLast
End Sub
DELETE:
Private Sub Command7_Click()
Adodc1.Recordset.Delete
End Sub
MOVEPREVIOUS:
Private Sub Command8_Click()
Adodc1.Recordset.MovePrevious
End Sub
CLEAR:
Private Sub Command9_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
8/13/2019 cs2258 Dbms Record
89/93
89
Text9.Text = ""
End Sub
Private Sub Label3_Click()
End Sub
FORM 1:
Option for ADODC1 is set enabled.
8/13/2019 cs2258 Dbms Record
90/93
90
FORM 2:
Build the connection string as provider=MSDAORA.1
FORM 3:;
Security is provided atthi stage.
8/13/2019 cs2258 Dbms Record
91/93
91
FORM 4:
Form for datareport size at final step of the process.
FORM 5:
Database connection is provided.
8/13/2019 cs2258 Dbms Record
92/93
92
FORM 6:
Properties for data environment is set with the username and password.
FORM 7:
Report is generated.
8/13/2019 cs2258 Dbms Record
93/93
FORM 8:
Drag data content from command1 to datareport.
FORM 9:
Finally the datareport is generated from the database.