0% found this document useful (0 votes)
96 views

DBMSLabManual Suresh

This document provides a lab manual for a Database Management Systems lab. It outlines three units of exercises focusing on SQL, PL/SQL programming, and cursors/triggers. The introduction provides an overview of DBMS and Oracle. Unit I covers SQL concepts like creating tables, inserting data, queries with functions and joins. Unit II covers PL/SQL concepts like blocks, exceptions, functions and packages. Unit III covers cursors, triggers and their uses. The document provides learning objectives and a week-by-week plan to guide students through hands-on exercises exploring these DBMS topics.

Uploaded by

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

DBMSLabManual Suresh

This document provides a lab manual for a Database Management Systems lab. It outlines three units of exercises focusing on SQL, PL/SQL programming, and cursors/triggers. The introduction provides an overview of DBMS and Oracle. Unit I covers SQL concepts like creating tables, inserting data, queries with functions and joins. Unit II covers PL/SQL concepts like blocks, exceptions, functions and packages. Unit III covers cursors, triggers and their uses. The document provides learning objectives and a week-by-week plan to guide students through hands-on exercises exploring these DBMS topics.

Uploaded by

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

DEPARTMENT OF MCA

DBMS LAB
Prepared by
M SURESH
SPHOORTHY ENGINEERING COLLEGE
Department of MCA DBMS Lab Manual
TABLE OF CONTENTS
S. No Topic Page No
1 Lab Objectives 4
2 Lab Plan 5
3 Introduction 7
4 Unit I 8
5 Exeri!ent 1 1"
# Exeri!ent 2 1"
7 Exeri!ent 3 1"
8 Exeri!ent 4 11
$ Exeri!ent 5 11
1" Exeri!ent # 11
11 Exeri!ent 7 11
12 Exeri!ent 8 12
13 Exeri!ent $ 12
14 Exeri!ent 1" 12
15 Exeri!ent 11 13
1# Exeri!ent 12 13
17 Exeri!ent 13 13
18 Exeri!ent 14 13
1$ Exeri!ent 15 14
2" Exeri!ent 1# 14
21 Exeri!ent 17 14
22 Exeri!ent 18 14
23 Exeri!ent 1$ 15
24 %dditional Exercises &or Unit I 1#
25 Unit II 17
2# Exeri!ent 2" 21
27 Exeri!ent 21 21
28 Exeri!ent 22 21
2$ Exeri!ent 23 21
3" Exeri!ent 24 22
31 Exeri!ent 25 22
32 Exeri!ent 2# 22
33 Exeri!ent 27 22
34 Exeri!ent 28 23
35 Exeri!ent 2$ 23
3# Exeri!ent 3" 23
37 Exeri!ent 31 23
38 Exeri!ent 32 23
3$ %dditional Exercises &or Unit II 25
SPHOORTHY Engineering College 2
Department of MCA DBMS Lab Manual
4" Unit III 2#
41 Exeri!ent 33 2$
42 Exeri!ent 34 2$
43 Exeri!ent 35 2$
44 Exeri!ent 3# 3"
45 Exeri!ent 37 3"
4# Exeri!ent 38 3"
47 Exeri!ent 3$ 3"
48 Exeri!ent 4" 31
4$ Exeri!ent 41 31
5" Exeri!ent 42 31
51 %dditional Exercises &or Unit III 32
52 'ule!entar( Exercises 33
53 )e&erences 33
SPHOORTHY Engineering College 3
Department of MCA DBMS Lab Manual
LAB OBJECTIVES
% vast !ajorit( o& t*e so&t+are alications bein, built use so!e -ind o& a data store
!ec*anis! to er!anentl( store t*e data ,enerated.used b( t*e so&t+are/ 0atabase
!ana,e!ent s(ste!s are co!lex so&t+are s(ste!s t*at rovide a +ide variet( o&
&unctionalit( &or users to structure1 or,ani2e and access data 3uic-l( and e&&icientl(/
0atabase s(ste!s *ave been t*ere since t*e earl( 1$7"4s but *ave ,ro+n in co!lexit(
and si2e/ )elational database !ana,e!ent s(ste!s use relational al,ebra as t*e basis &or
reresentation o& data/ )056' as relational database !ana,e!ent s(ste!s are t*e !ost
oular and +idel( used 056' in t*e !ar-et lace/
In t*is lab1 (ou +ould be exosed to one oular )056'/ 7*e broad one line objective o&
t*e lab is to ,et &a!iliar +it* t*e &unctionalit( and suort rovided b( co!!erciall(
oular )056' and understand *o+ to use it to !eet (our data stora,e and or,ani2ation
re3uire!ents/
0etailed objectives o& t*e lab are8
9ou learn ':L ;'tructured :uer( Lan,ua,e< +*ic* +ould rovide &unctionalit( to8
o Learn *o+ to create tables +*ic* are &unda!ental stora,e bloc-s o& data/
o Learn *o+ to lace constraints on data t*at is entered on tables to ensure
data inte,rit(/
o Learn *o+ to add1 c*an,e and re!ove data &ro! tables/
o Learn *o+ to select a subset o& t*e data (ou +ant to see &ro! t*e collection
o& tables and data/
o Learn *o+ to co!bine table and ,rou !ultile ro+s o& data in table/
9ou learn PL.':L +*ic* +ould rovide t*e abilit( to do iterative ro,ra!!in, at
database level to8
o =rite ro,ra!!in, bloc-s +it* conditionals1 assi,n!ents1 loos1 etc
o Excetion >andlin,/
o 7ransaction oriented ro,ra!s
o 'tored rocedures1 &unctions1 ac-a,es/
o ?ursors +*ic* +ould allo+ ro+ +ise access o& data/
o 7ri,,ers +*ic* +ould allo+ (ou de&ine re and ost actions +*en so!et*in,
c*an,es in t*e database tables/
%t t*e end o& t*e lab1 (ou s*ould be co!&ortable usin, an( oular )056' &or data
access and udatin, and s*ould be co!&ortable +ritin, PL.':L ro,ra!s at database
level usin, Oracle/
SPHOORTHY Engineering College 4
Department of MCA DBMS Lab Manual
LAB PLAN
Introduction:
=ee- 18 Oracle $i setu @ connectin, to Oracle &ro! ':LAPlus/
Unit I S!L":
=ee- 28 ?reatin,1 %lterin,1 0roin, tables +it* ?onstraints1 Insert 7able/
Exeri!ent 18 ?reate 7ables
Exeri!ent 28 %lter table +it* c*an,es in colu!ns
Exeri!ent 38 %lter table +it* constraints
Exeri!ent 48 0roin, 7ables
Exeri!ent 58 Insertin, 0ata into 7ables/
=ee- 38 Insertin,1 'i!le 'elect1 ?*ar1 Bu!ber1 0ate &unctions
Exeri!ent #8 'i!le 'elect
Exeri!ent 78 'elect +it* conditions/
Exeri!ent 88 Usin, c*aracter &unctions/
Exeri!ent $8 Usin, nu!ber &unctions/
Exeri!ent 1"8 Usin, date &unctions/
=ee- 48 0etailed 'ELE?7 +it* subC3ueries1 E:UICDOIB'1 correlated subC3ueries/
Exeri!ent 118 'in,le ro+ subC3ueries/
Exeri!ent 128 6ultile ro+ subC3ueries/
Exeri!ent 138 E3ual joins/
Exeri!ent 148 correlated subC3ueries/
=ee- 58 E)OUPIBE1 'E71 UP0%7E1 0ELE7E1 FIE='
Exeri!ent 158 %,,re,ate &unctions/
Exeri!ent 1#8 Erouin, clauses
Exeri!ent 178 'elect ,rous +it* *avin,
Exeri!ent 188 Union.Intersection state!ents
Exeri!ent 1$8 ?reatin, and droin, vie+s/
=ee- #8 5ac- Lo,s1 i& an( and.or %dditional Exercises &or Unit I/
Unit II PL#S!L: Progra$ %e&e'op$ent":
SPHOORTHY Engineering College 5
Department of MCA DBMS Lab Manual
=ee- 78 Iterative PL.':L 5loc-s and &unctions/
Exeri!ent 2"8 'i!le PL.':L 5loc-s
Exeri!ent 218 Bested IG and ?%'E in PL.':L
Exeri!ent 228 BULLIG and ?O%LE'?E &unctions
Exeri!ent 238 =>ILE @ GO) Loos
=ee- 88 7ransaction suort in PL.':L
Exeri!ent 248 ?O66I7 @ )OLL5%?H
Exeri!ent 258 '%FEPOIB7'
=ee- $8 Excetion suort in PL.':L
Exeri!ent 2#8 Excetion 5loc-s
Exeri!ent 278 5UIL7CIB Excetions
Exeri!ent 288 User de&ined Excetions
Exeri!ent 2$8 )aisin, alication error
=ee- 1"8 Gunctions1 Procedures1 Pac-a,es
Exeri!ent 3"8 ?reatin, 'tored Procedures +it* Para!eters/
Exeri!ent 318 ?reatin, 'tored Gunctions +it* Para!eters/
Exeri!ent 328 Erouin, 'tored Pac-a,es/
=ee- 118 5ac- Lo,s1 i& an( and.or %dditional Exercises &or Unit II/
Unit III PL#S!L: Cur(or( ) Trigger("
=ee- 128 0eclare1 Getc*1 Oen1 and ?lose ?ursors
Exeri!ent 338 0eclarin, ?ursors/
Exeri!ent 348 Oenin, @ ?losin, ?ursors/
Exeri!ent 358 Getc* &ro! an oen ?ursor/
Exeri!ent 3#8 %ccessin, current ro+ in t*e cursor/
=ee- 138 5e&ore @ %&ter I)o+ and 'tate!ent 7ri,,ersJ1 Instead o& 7ri,,ers/
Exeri!ent 378 ?reatin, 5e&ore 'tate!ent 7ri,,er/
Exeri!ent 388 ?reatin, %&ter 'tate!ent 7ri,,er/
Exeri!ent 3$8 ?reatin, 5e&ore )o+ 7ri,,er/
Exeri!ent 4"8 ?reatin, %&ter )o+ 7ri,,er/
Exeri!ent 418 ?reatin, 7ri,,ers +it* +*en condition/
Exeri!ent 428 ?reatin, instead o& tri,,ers to relaces udatin, &ro! vie+s/
=ee- 148 5ac- Lo,s1 i& an( and.or %dditional Exercises &or Unit III
SPHOORTHY Engineering College 6
Department of MCA DBMS Lab Manual
Introduction
)056' is one o& t*e !ost +idel( used lu,,able so&t+are co!onents in !ost enterrise
so&t+are alications/ 7*ou,* )056' alications *ave been t*ere since t*e earl( 1$7"s1
t*e( *ave i!roved tre!endousl( in ter!s o& t*eir &eatures1 t*e si2e o& data t*e( can
*old1 and t*e co!lexit( over t*e last 2" (ears/
Oracle is one o& t*e ver( +idel( used co!!ercial )056' s(ste!s and at t*is oint is t*e
!ar-et leader as &ar as )056' is concerned/ Oracle$i is )056' so&t+are +*ic* suorts
':L 1$$$/ It also suorts ro,ra!!in, lan,ua,e extension to ':L called PL.':L +*ic*
is Oracle rorietar( and is ver( oular to do ro,ra! develo!ent at t*e database
server level/ Ot*er oular 056' so&t+are li-e '(base and ':L 'erver suort t*eir o+n
ro,ra!!in, extensions to ':L 1$$$/
SPHOORTHY Engineering College 7
Department of MCA DBMS Lab Manual
UNIT I S!L"
':L ;'tructured :uer( Lan,ua,e< is a standard suorted b( all t*e oular relational
database !ana,e!ent s(ste!s in t*e !ar-et lace/ 7*e basis data structure in )056' is a
table/ ':L rovides (ou t*e &eatures to de&ine tables1 de&ine constraints on tables1 3uer(
&or data in table1 and c*an,e t*e data in table b( addin,1 !odi&(in,1 and re!ovin, data/
':L also suorts ,rouin, o& data in !ultile ro+s1 co!binin, tables and ot*er &eatures/
%ll t*ese ut to,et*er1 ':L is a *i,*Clevel 3uer( lan,ua,e standard to access and alter
data in )056'/
:uer(in, &or 0ata8
7*e t(ical s(ntax to 3uer( &or data isK
'ELE?7 clause
G)O6 clause
=>E)E clause
7*ere are o& course a &e+ ot*er additions to t*ese standard clauses/
E)OUP 59
>%FIBE
:uer(in, can be used to8 7o retrieve existin, data &ro! database/
Eet all data &ro! t*e table
Eet selected colu!ns &ro! t*e table/
Eet selected ro+s &ro! t*e table/
Eet selected colu!ns o& selected ro+s &ro! t*e table/
Eet co!uted colu!ns usin, c*ar1 nu!ber1 data &unctions1 ,eneral &unctions1 and
a,,re,atin, &unctions/
Eet data in !ultile ro+s ,roued on an a,,re,atin, &unction alied on one or
!ore colu!ns/
'elect seci&ic a,,re,atin, data on !ultile ro+s usin, *avin, clause/
%l( set oerations li-e Union and Intersection on data sets o& t*e sa!e
cardinalit( and t(e/
Eet data &ro! !ultile tables usin, ?artesian roduct1 e3ualit( join1 unCe3ual join1
and outer join/
?reate vie+s on *(sical data/
0ata 0e&inition Lan,ua,e ;00L<8 7o do +it* alterin, t*e structure o& data base/
SPHOORTHY Engineering College 8
Department of MCA DBMS Lab Manual
?reate tables/
?reate Indexes on tables/
%lter tables
%dd constraints to tables/
0ro tables/
7runcate tables/
0ro indexes/
?reate se3uences/
0ata 6aniulation Lan,ua,e ;06L<8 7o do +it* addin,1 udatin,1 and deletin, data &ro!
tables/
Insert 0ata
Udate 0ata
0elete 0ata
6er,e 7ables/
0ata ?ontrol Lan,ua,e ;0?L<8 7o do +it* controllin, access to data in tables/
Erant Per!issions
)evo-e Per!issions
?reate and udate roles/
%dd users to roles/
%s (ou can see &ro! above1 ':L ,ives (ou all t*e tools needed to de&ine (our database in
t*e &or! o& table1 de&ine inte,rit( constraint rules on table to ensure data inte,rit(1
c*an,e t*e database as needed and control er!issions on tables at a ver( &ine ,ranular
level/
':L 1$$$ is t*e standard +*ic* is suorted b( all co!!ercial database vendors/ I& (our
3ueries are usin, ':L 1$$$ standard1 t*e( +ill run all )056' servers/ In addition to t*e
':L 1$$$ standard1 !ost co!!ercial databases *ave t*eir o+n extensions to ':L
suorted b( t*e!/ In t*e interest o& ortabilit(1 it +ould be ,ood i& +e stic- +it* ':L
1$$$ standard in our 3uer(in, no !atter +*at )056' +e are usin, unless +e *ave a stron,
reason to ,o &or additional &eatures not included in ':L 1$$$ standard/
SPHOORTHY Engineering College 9
Department of MCA DBMS Lab Manual
E*peri$ent I:
Proble! 'tate!ent8
?reate location1 deart!ent1 jobL,rade1 and e!lo(ee tables +it* t*e &ollo+in, colu!ns/
Location8 ;locationLid8nu!ber1 cit(8strin,<
0eart!ent8 ;deart!entLid8nu!ber1 deart!entLna!e8strin,1 *ead8nu!ber1
deart!entLlocation8nu!ber<
DobL,rade8 ;jobL,rade8strin,1 lo+erLbound8nu!ber1 uerLbound8nu!ber<
E!lo(ee8 ;e!lo(eeLid8nu!ber1 &irstLna!e8strin,1 lastLna!e8strin,1 joinLdate8date1
!ana,erLid8nu!ber1 salar(8nu!ber<
'olution8
1/ Understand create table s(ntax/
2/ 0ecide t*e na!e o& t*e table/
3/ 0ecide t*e na!e o& eac* colu!n and its data t(e/
4/ Use t*e create table s(ntax to create t*e said tables/
5/ ?reate ri!ar( -e( constraint &or eac* table as understand &ro! lo,ical table
structure/
E*peri$ent +:
Proble! 'tate!ent8
%lter e!lo(ee table to add jobL,rade colu!n +*ic* is o& strin, data t(e/
'olution8
1/ Learn alter table s(ntax/
2/ 0e&ine t*e ne+ colu!n and its data t(e/
3/ Use t*e alter table s(ntax/
E*peri$ent ,:
Proble! 'tate!ent8
%lter e!lo(ee table to !a-e jobL,rade a &orei,n -e( to jobL,rade table1 !ana,erLid a
&orei,n -e( to e!lo(ee table1 deart!entLid a &orei,n -e( to deart!ent table/
'olution8
SPHOORTHY Engineering College
10
Department of MCA DBMS Lab Manual
4/ Learn alter table s(ntax/
5/ 0e&ine t*e ne+ constraint It(e1 na!e1 colu!ns e&&ectedJ
#/ Use t*e alter table s(ntax &or addin, constraints/
E*peri$ent -:
Proble! 'tate!ent8
?reate a du!!( table called !(Le!lo(ee +it* t*e sa!e de&inition as e!lo(ee table
and t*an dro t*e table/
'olution8
1/ Use create table to create !(Le!lo(ee/
2/ Use dro table to dro !(Le!lo(ee/
E*peri$ent .:
Proble! 'tate!ent8
Insert data into location1 deart!ent1 jobL,rade @ e!lo(ee tables/
'olution8
1/ 0ecide t*e data to add in location/
2/ %dd to location one ro+ at a ti!e usin, insert into s(ntax
3/ 0ecide t*e data to add in deart!ent/
4/ %dd to deart!ent one ro+ at a ti!e usin, insert into s(ntax/
5/ 0ecide t*e data to add in jobL,rade/
#/ %dd to jobL,rade one ro+ at a ti!e usin, t*e insert into s(ntax/
7/ 0ecide t*e data to add in e!lo(ee/
8/ %dd to e!lo(ee one ro+ at a ti!e usin, t*e insert into s(ntax/
E*peri$ent /:
Proble! 'tate!ent8
Eive a list o& all e!lo(ees ;na!es as &irstLna!e1 lastLna!e< +*o belon, to one
deart!entLid/
'olution8
1/ use 'ELE?7 G)O6 =>E)E s(ntax/
2/ select s*ould include &irstLna!e and lastLna!e in t*e ,iven &or!at/
3/ &ro! s*ould include e!lo(ee
4/ +*ere s*ould include condition on deart!entLid
SPHOORTHY Engineering College
11
Department of MCA DBMS Lab Manual
E*peri$ent 0:
Proble! 'tate!ent8
'elect e!lo(ee lastLna!es &ro! e!lo(ee table +*o belon, to a certain deart!entLid
and *ave a salar( ,reater t*an 5"""/
'olution8
1/ Use 'ELE?7 G)O6 =>E)E s(ntax/
2/ Use %B0 oerator &or 2 conditions in =>E)E/
E*peri$ent 1:
Proble! 'tate!ent8
'elect e!lo(ee lastLna!e +it* &irst letter in caital1 all s!alls and all caitals &ro!
e!lo(ee table &or all e!lo(ees/
'olution8
1/ Use select &ro! +*ere clause/
2/ Use initca1 lo+er1 and uer &unctions on lastLna!e in select clause to ,et t*e
result/
E*peri$ent 2:
Proble! 'tate!ent8
'elect t*e salar( and additional >)% ;7/5M o& t*e salar(< &or eac* e!lo(ee in e!lo(ee
table rounded to a +*ole nu!ber/
'olution8
1/ Use select &ro! +*ere clause and arit*!etic to co!ute >)%/
2/ Use t*e round &unction to round o&& t*e co!uted >)% to t*e nearest +*ole
nu!ber/
E*peri$ent 34:
Proble! 'tate!ent8
'elect e!lo(ee lastLna!e1 joinLdate1 and t*e nu!ber o& da(s *e.s*e *as been +or-in,
in t*e &ir! as o& toda(/
'olution8
SPHOORTHY Engineering College
12
Department of MCA DBMS Lab Manual
1/ Use t*e select &ro! +*ere clause/
2/ In t*e clause1 ,et t*e current data usin, s(sdate &unction1 ,et t*e di&&erence
bet+een s(sdate and e!lo(ee joinin, date and co!ute t*e da(s in bet+een
usin, t*e da(sLbet+een date &unction/
3/ '*o+ t*e joinLdate usin, !!.dd.(((( &or!at to usin, toLc*ar &unction/
E*peri$ent 33:
Proble! 'tate!ent8
'elect e!lo(ee lastLna!e o& all e!lo(ees +*ose salar( is ,reater t*an t*e salar( o&
e!lo(ee +it* id N 2/
'olution8
1/ Use an inner 3uer( to &irst ,et t*e salar( o& e!lo(eeLid N 2/
2/ 7*e result &ro! t*e inner 3uer( is t*an ,iven in t*e +*ere clause o& t*e outer 3uer(
t*at selects all e!lo(ees +it* salar( ,reater t*an t*at/
E*peri$ent 3+:
Proble! 'tate!ent8
'elect all e!lo(ees +*ose salar( is ,reater t*an t*e salaries o& bot* e!lo(ees +it* ids 2
@ 3/
'olution8
3/ Use an inner 3uer( to &irst ,et t*e salar( o& e!lo(eeLid in ;213</
4/ 7*e result &ro! t*e inner 3uer( is t*an ,iven in t*e +*ere clause o& t*e outer 3uer(
usin, t*e all oerator t*at selects all e!lo(ees +it* salar( ,reater t*an t*at/
E*peri$ent 3,:
Proble! 'tate!ent8
'elect e!lo(ee lastna!e and t*e corresondin, deart!entLna!e &or all e!lo(ees in
e!lo(ees table/
'olution8
1/ Use select &ro! +*ere clause +it* t*e &ro! co!in, &ro! e!lo(ee and deart!ent
tables and a condition joinin, t*ese t+o table usin, t*e &orei,n -e( deart!entLid +*ic*
connects bot* t*e tables +it* an e3ualit( condition/
SPHOORTHY Engineering College
13
Department of MCA DBMS Lab Manual
E*peri$ent 3-:
Proble! 'tate!ent8
'elect all e!lo(ees +*ose salar( is lesser t*an all e!lo(ees in t*e sa!e job ,rade/
'olution8
1/ Use t*e correlated subC3uer( +*ere t*e inner 3uer( +ill be !ade based on t*e data
co!in, &ro! t*e uer 3uer(/ In t*is case1 t*e salar( and ,rade o& eac* e!lo(ee
ro+ is used to execute t*e inner 3uer( to co!are i& t*ere are an( e!lo(ees in
t*e sa!e ,rade +*o *ave lesser salar( usin, exists clause/
E*peri$ent 3.:
Proble! 'tate!ent8
'elect t*e avera,e salar( o& all e!lo(ees in deart!ent +it* deart!entLid N 2/
'olution8
1/ Use t*e %FE a,,re,ate &unction in select clause/
2/ Use t*e deart!entLid N 2 condition in +*ere clause/
E*peri$ent 3/:
Proble! 'tate!ent8
'elect %FE salar( o& eac* deart!ent +*ic* *as e!lo(ees in e!lo(ee table/
'olution8
1/ Use t*e %FE a,,re,ate &unction in select clause/
2/ 'ince +e +ant avera,e er deart!ent1 *ave deart!entLid in select clause/
3/ Include a ,rouin, clause b( deart!entLid to indicate (ou +ant to a,,re,ate data
b( deart!entLid
E*peri$ent 30:
Proble! 'tate!ent8
'elect !ini!u! salar( o& all deart!ents +*ere t*e !ini!u! salar( is less t*an 1"""/
'olution8
4/ Use t*e 6IB a,,re,ate &unction in select clause/
5/ 'ince +e +ant avera,e er deart!ent1 *ave deart!entLid in select clause/
#/ Include a ,rouin, clause b( deart!entLid to indicate (ou +ant to a,,re,ate data
b( deart!entLid/
SPHOORTHY Engineering College
14
Department of MCA DBMS Lab Manual
7/ Exclude ,rouin,s +*ic* *ave a !ini!u! salar( ,reater t*an 1""" usin, *avin,
clause/
E*peri$ent 31:
Proble! 'tate!ent8
Eive a list o& all e!lo(ees +*o earn a salar( ,reater t*an 1"""" or +or- in job ,rade
6%B%EE)/
'olution8
1/ =rite a select &ro! +*ere +*ic* ,ives all e!lo(ees +it* salar( ,reater t*an
1""""/
2/ =rite a select &ro! +*ere +*ic* ,ives all e!lo(ees +*ose job ,rade in !ana,er/
3/ ?o!bine t*e! usin, UBIOB clause/
E*peri$ent 32:
Proble! 'tate!ent8
?reate a vie+ t*at s*o+s all e!lo(ees o& deart!entLid N 1" and select &ro! t*e vie+/
'olution8
1/ ?reate vie+ +it* t*e select clause on e!lo(ees table +it* t*e said condition/
2/ =rite a select state!ent usin, t*e vie+ created instead o& table +*enever (ou
need e!lo(ees o& deart!entLid N 1"/
SPHOORTHY Engineering College
15
Department of MCA DBMS Lab Manual
Unit I Additiona' E*erci(e(
1/ =rite a 3uer( t*at +ould ,ive t*e e!lo(ee na!e1 *is salar( and t*e lo+er end and
*i,*er end salaries o& *is job ,radeO
2/ =rite a 3uer( t*at +ould ,ive t*e e!lo(ee na!e and *is deart!ent na!e usin,
natural join/
3/ =rite a 3uer( +*ic* +ould ,ive all e!lo(ee na!es and t*eir deart!ent na!es/
7*e 3uer( s*ould also return e!lo(ees +*o are currentl( not allotted to an(
deart!ent and deart!ents t*at do not *ave an( e!lo(ees/
4/ =rite a 3uer( to !er,e deart!ent level e!lo(ee table data c*an,es to colle,e
level e!lo(ee table on a eriodic basis/
5/ I +ant to insert a lot o& records in e!lo(ee table +*ic* *as certain constraints on
salar(/ I -no+ all records I a! insertin, +ould be ,ood in salar( &ield/ 7r(in,
insertin, as is and +it* t*e salar( constraint disable be&ore bul- insert and enable
a&ter insert and see t*e ti!e di&&erence/
#/ ?reate index o& salar( colu!n o& e!lo(ee and searc* &or all e!lo(ees +it* a
certain salar(/
7/ Instead o& ,ivin, a uni3ue I0 (oursel&1 +*at can be done to auto!aticall( ,enerate
uni3ue I0/

SPHOORTHY Engineering College
16
Department of MCA DBMS Lab Manual

UNIT II PL#S!L"
PL.':L is t*e rocedural extension to ':L +it* desi,n &eatures o& ro,ra!!in, lan,ua,es/
0ata !aniulation and 3uer( state!ents o& ':L are included +it*in rocedural units o&
code/
5ene&its o& PL.':L8
PL.':L can i!rove t*e er&or!ance o& an alication/ 7*e bene&its di&&er deendin, on
t*e execution environ!ent8
PL.':L can be used to ,rou ':L state!ents to,et*er +it*in a sin,le bloc- and to
send t*e entire bloc- to t*e server in a sin,le call t*ereb( reducin, net+or-in,
tra&&ic/ =it*out PL.':L1 t*e ':L state!ents are sent to t*e Oracle server one at a
ti!e/ Eac* ':L state!ent results in anot*er call to t*e Oracle server and *i,*er
er&or!ance over*ead/ In a net+or- environ!ent1 t*e over*ead can beco!e
si,ni&icant/
PL.':L can also oerate +it* Oracle server alication develo!ent tools suc* as
Oracle &or!s and Oracle reorts/
PL.':L 5loc- 'tructure8
Ever( unit o& PL.':L co!rises one or !ore bloc-s/ 7*ese bloc-s can be entirel( searate
or nested one +it*in anot*er/ 7*e basic units ;rocedures1 &unctions1 and anon(!ous
bloc-s< t*at !a-e u a PL.':L ro,ra! are lo,ical bloc-s +*ic* can contain an( nu!ber
o& nested subCbloc-s/ 7*ere&ore one bloc- can reresent a s!all art o& anot*er bloc-1
+*ic* in turn can be art o& t*e +*ole unit o& code/
6odulari2ed ro,ra! develo!ent8
Erou lo,icall( related state!ents +it*in bloc-s/
SPHOORTHY Engineering College
17
Department of MCA DBMS Lab Manual
Best subCbloc-s inside lar,er bloc-s to build o+er&ul ro,ra!s/
5rea- do+n a co!lex roble! into a set o& !ana,eable +ell de&ined lo,ical
!odules and i!le!ent t*e !odules +it* bloc-s/
Place reusable PL.':L code in libraries to be s*ared bet+een Oracle &or!s and
Oracle reorts1 alications1 or store it in a Oracle server to !a-e it accessible to
an( alication t*at can interact +it* an Oracle database/
Identi&iers.Fariables8
In PL.':L1 (ou can use identi&iers to do t*e &ollo+in,8
0eclare variables1 cursors1 constants and excetions and t*en use t*e! in ':L and
rocedural state!ents/
0eclare variables belon,in, to scalar1 re&erence1 co!osite and lar,e object ;LO5<
data t(es/
0eclare variables d(na!icall( based on t*e data structure o& tables and colu!ns in
t*e database/
Procedural Lan,ua,e ?ontrol 'tructures8
Execute a se3uence o& state!ents conditionall(/
Execute a se3uence o& state!ents iterativel( in a loo/
Process individuall( t*e ro+s returned b( a !ultile ro+ 3uer( +it* a cursor/
Errors8
Process Oracle server error +it* excetionC*andlin, routines/
0eclare userCde&ined error conditions and rocess t*e! +it* excetionC*andlin,
routines/
PL.':L 5loc- '(ntax8
0E?L%)E IOtionalJ
Fariables1 cursors1 user de&ined excetions
5EEIB I6andator(J
C ':L 'tate!ents
C PL.':L 'tate!ents
Excetion IOtionalJ
CC %ctions to be er&or!ed +*en errors occur CCCC
EB0 I6andator(JK
Exa!le8
0E?L%)E
vLvariable F%)?>%)2;5<K
5EEIB
'ELE?7 colu!nLna!e
IB7O vLvariable
G)O6 tableLna!eK
EP?EP7IOB
SPHOORTHY Engineering College
18
Department of MCA DBMS Lab Manual
=>EB excetionLna!e 7>EB
C
C
C
EB0K
%non(!ous1 rocedure and &unction bloc-s8
%non(!ous8
C Bo na!e/
C 'tarts +it* 0E?L%)E state!ent/
Procedure8
C Bo return/
C P)O?E0U)E na!e I'
Gunction8
C )eturns a value
C GUB?7IOB na!e )E7U)B dataCt(e I'
Pro,ra!!in, ?onstructs8
C 0eclarin, Fariables8
o Identi&ier I?OB'7%B7J dataCt(e IBO7 BULLJ
I8N Q 0EG%UL7 exrJK
C %ssi,n!ent8
o Identi&ier 8N exrK
C IG 'tate!ent8
o IG condition 7>EB
'tate!entsK
IEL'E IG condition 7>EB
'tate!entsKJ
IEL'E
'tate!entsKJ
EB0 IGK
C ?%'E 'tate!ent8
o ?%'E selector
=>EB exression1 7>EB result1
=>EB exression2 7>EB result2
/
/
/
=>EB exression 7>EB resultn
SPHOORTHY Engineering College
19
Department of MCA DBMS Lab Manual
IEL'E resultn1KJ
EB0K
C 5%'I? Loos8
o LOOP
'tate!ent 1K
/
/
/
EPI7 I=>EB conditionJK
EB0 LOOPK

C =>ILE 'tate!ent8
o =>ILE condition LOOP
'tate!ent1K
/
/
/
EB0 LOOPK
C GO) 'tate!ent8
o GO) counter IB I)EFE)'EJ
Lo+erLbound//uerLbound LOOP
'tate!ent1K
/
/
/
EB0 LOOPK
Pac-a,es8
Pac-a,es are collections o& variables1 user de&ined data t(es1 rocedures and &unctions
+*ic* can eit*er be eit*er ublic or rivate/ Pac-a,es are used to ,rou related t*in,s
into one bloc- t*at ,et loads into !e!or( in one ,o/ % ac-a,e cannot be invo-ed
directl(/
SPHOORTHY Engineering College
20
Department of MCA DBMS Lab Manual
E*peri$ent +4:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares a variable and reads t*e last na!e o& e!lo(ee +it*
id N 5 and oututs t*at to standard outut/
'olution8
1/ 0eclare a varc*ar variable
2/ =rite t*e select into clause inside PL.':L 5e,in EB0 bloc-/
E*peri$ent +3:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares a variable +it* a value and rints in all caitals i& t*e
value starts +it* R'41 in all s!alls i& it starts +it* R)41 and in initial caitals i& ot*er+ise/
'olution8
1/ Use IG or ?%'E/
E*peri$ent ++:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares t+o variables +it* values and rints &irst value i& it is
not null and rints second value i& &irst is null/
'olution8
SPHOORTHY Engineering College
21
Department of MCA DBMS Lab Manual
Use BULLIG or ?O%LE'?E/
E*peri$ent +,:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares a variable and reads t*e last na!e o& e!lo(ees and
oututs t*at to standard outut/
'olution8
3/ 0eclare a varc*ar variable
4/ =rite a LOOP/
E*peri$ent +-:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* udates 2 tables/ I& t*e second udate &ails t*e &irst udate
also *as to be reversed/
'olution8
1/ Use 5EEIB transaction1 EB0 transaction/
2/ ?*ec- &or success o& a 3uer(/
3/ Use )OLL5%?H or ?O66I7 deendin, on 3uer( success/
E*peri$ent +.:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* udates 3 tables/ I& t*e t*ird udate &ails t*e second udate
*as to be reversed +*ile &irst s*ould not ,et e&&ected/
'olution8
1/ Use 5EEIB transaction1 EB0 transaction/
2/ 0e&ine '%FEPOIB7 at t*e end o& &irst udate/
3/ )un 3
rd
udate and c*ec- &or success/
4/ I& 3
rd
&ails1 Use )OLL5%?H to '%FEPOIB7/
E*peri$ent +/:
Proble! 'tate!ent8
SPHOORTHY Engineering College
22
Department of MCA DBMS Lab Manual
=rite a PL.':L bloc- +it* a si!le Excetion 5loc-/
'olution8
1/ )e&er to Excetion bloc- s(ntax/
E*peri$ent +0:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares a variable and reads t*e last na!e o& e!lo(ee +it*
id N 5/ I& t*ere is no e!lo(ee +it* id N 5 an error s*ould be t*ro+n/ Ot*er+ise t*e na!e
*as to be rinted/

'olution8
1/ Use builtCin excetions/
E*peri$ent +1:
Proble! 'tate!ent8
=rite a PL.':L bloc- +*ic* declares a variable and reads t*e last na!e o& e!lo(ee +it*
id N 5/ I& t*e na!e *as 8 c*aracters1 raise an excetion called too !an( c*aracters and
*andle it b( cuttin, t*e lastLna!e to &irst ei,*t c*aracters/

'olution8
1/ Use user de&ined excetions/
E*peri$ent +2:
Proble! 'tate!ent8
7*in- o& a roble! t*at ,enerates an excetion is cau,*t but an alication error *as to
be raised because t*e excetion in &atal/
'olution8
1/ %s a art o& excetion *andlin,1 raise alication error i& t*e situation is not
recoverable/
E*peri$ent ,4:
Proble! 'tate!ent8
?reate a stored rocedure +*ic* ta-es dear!entLid as ara!eter1 inserts all e!lo(ees
o& t*at deart!ent in a table called detLe!lo(ee +it* t*e sa!e structure/
SPHOORTHY Engineering College
23
Department of MCA DBMS Lab Manual
'olution8
1/ Learn *o+ to use ara!eter in to stored rocedure/
E*peri$ent ,3:
Proble! 'tate!ent8
?reate a &unction +*ic* ta-es dear!entLid as ara!eter and returns t*e na!e o& t*e
deart!ent/
'olution8
1/ Learn *o+ to use ara!eter in &unctions/
E*peri$ent ,+:
Proble! 'tate!ent8
=rite a ac-a,e +*ic* i!le!ents a set o& &unctions t*at +ill co!ute >)%1 0% based on
rules ,iven salar(/
'olution8
1/ I!le!ent one stored &unction t*at +ill co!ute >)% ,iven basic/
2/ I!le!ent one stored &unction t*at +ill co!ute 0% ,iven basic/
3/ Put t*ese in a ac-a,e so it ,ets loaded at one ti!e/
SPHOORTHY Engineering College
24
Department of MCA DBMS Lab Manual
Unit II Additiona' E*erci(e(
1/ =rite a PL.':L rocedure +*ic* ta-es deart!ent id as ara!eter and ,ives all
e!lo(ees belon, to t*e deart!ent/
2/ =rite a PL.':L rocedure +*ic* ta-es lo+est and *i,*est salar( as ara!eters and
returns all e!lo(ees +it*Cin t*at salar( ran,e/ I& t*ere re no e!lo(ees1 an
excetion *as to be raised and an alication error to be ,ivenO
3/ =rite a PL.':L rocedure +*ere (ou de&ine (our o+n user excetions and *andle
excetions aroriatel(/
SPHOORTHY Engineering College
25
Department of MCA DBMS Lab Manual
Unit III Cur(or( ) Trigger("
Cur(or(:
Ever( ':L state!ent executed b( t*e Oracle server *as an individual cursor associated
+it* it and are called i!licit cursors/ 7*ere are t+o t(es o& cursors/
I!licit cursors8 0eclared &or all 06L and PL.':L 'ELE?7 state!ents/
Exlicit cursors8 0eclared and na!es b( t*e ro,ra!!er/
Exlicit ?ursors8
o Individuall( rocess eac* ro+ returned b( a !ultile ro+ select state!ent/
o % PL.':L ro,ra! oens a cursor1 rocesses ro+s returned b( a 3uer(1 and t*en
closes t*e cursor/ 7*e cursor !ar-s t*e current osition in t*e active set/
o ?an rocess be(ond t*e &irst ro+ returned b( t*e 3uer(1 ro+ b( ro+/
o Hee trac- o& +*ic* ro+ is currentl( bein, rocessed/
o %llo+ t*e ro,ra!!er to !anuall( control exlicit cursors in t*e PL.:L
bloc-/
?ontrollin, Exlicit ?ursors8
o 0eclare t*e cursor b( na!in, it and de&inin, t*e structure o& t*e 3uer( to be
er&or!ed/ =it*in it/
SPHOORTHY Engineering College
26
Department of MCA DBMS Lab Manual
o Oen t*e cursor8 7*e OPEB state!ent executes t*e 3uer( and binds t*e variables
t*at are re&erenced/ )o+s identi&ied b( t*e 3uer( are called t*e active set and are
no+ available &or &etc*in,/
o Getc* data &ro! t*e cursor8 %&ter eac* &etc*1 (ou test t*e cursor &or an( existin,
ro+/ I& t*ere are no !ore ro+s to rocess1 t*en (ou !ust close t*e cursor/
o ?lose t*e cursor8 7*e ?LO'E state!ent releases t*e active set o& ro+s/ It is no+
ossible to reoen t*e cursor to establis* a &res* active set/
'(ntax8
0eclarin, a cursor8
?U)'O) cursorLna!e I'
'electLstate!entK
Oenin, a cursor8
OPEB cursorLna!eK
Getc* data &ro! a cursor8
GE7?> cursorLna!e IB7O Ivariable11 variable21S/JQ recordLna!eJK
?losin, a cursor8
?lose cursorLna!eK
Exa!le8
'et 'E)FE)OU7PU7 OB
0E?L%)E
FLe!no e!lo(ees/e!lo(eeLidM79PEK
FLena!e e!lo(ees/lastLna!eM79PEK
?U)'O) e!Lcursor I'
'ELE?7 e!lo(eeLid1 lastLna!e
G)O6 e!lo(eesK
5EEIB
OPEB e!LcursorK
GO) I IB 1//1" LOOP
GE7?> e!Lcursor IB7O vLe!no1 bLena!eK
056'LOU7PU7/ PU7LLIBE ;7OL?>%);vLe!no< QQ R R QQ vLena!e<K
EB0 LOOP
?LO'E e!LcursorK
%ttributes o& an Exlicit ?ursor8
o MI'OPEB Iis cursor oenJ
SPHOORTHY Engineering College
27
Department of MCA DBMS Lab Manual
o MBO7GOUB0 Iis ro+ not &oundJ
o MGOUB0 Iis ro+ &oundJ
o M)O=?OUB7 Iro+s returned so &arJ
?ursors can be assed ara!eters/ ?ursors also *ave GO) UP0%7E otion +*ic* allo+s
!ore &ine ,rained control o& loc-in, at a table level/ =>E)E ?U))EB7 OG can be used to
al( t*e udate or delete oeration to current ro+ in t*e cursor/
Trigger(:
=*at are tri,,ersO
% tri,,er is a PL.':L bloc- or a PL.':L rocedure associated +it* a table1 vie+1 sc*e!a1
o& t*e database/ It executes i!licitl( +*enever a articular event ta-es lace/ It can
eit*er be8
1/ %lication tri,,er8 Gires +*enever an event occurs +it* a articular alication/
2/ 0atabase 7ri,,er8 Gires +*enever a data event ;suc* as 06L< occurs on a sc*e!a or
database/
=*en s*ould +e use tri,,ersO
7ri,,ers are to be used +*en +e +ant to er&or! related actions and +*en +e +ant to
centrali2e ,lobal oerations/ ?reate stored rocedures and invo-e t*e! in a tri,,er1 i& t*e
PL.':L code is ver( len,t*(/ 7*e excessive use o& tri,,ers can result in co!lex
interdeendencies1 +*ic* !a( be di&&icult to !aintain in lar,e alications/ 7ri,,ers
s*ould not be used +*ere &unctionalit( needed is alread( built into t*e Oracle server or
+*en it is dulicatin, +*at is done b( ot*er tri,,ers/
Exa!le8
% tri,,er called c*ec-Lsal +*ic* runs ever( ti!e a ne+ e!lo(ee is ,ettin, inserted to
en&orce so!e rules on +*at s*ould be t*e !ini!u! salar(/
Ele!ents in a 7ri,,er8
7ri,,er ti!in,
o Gor table8 5EGO)E1 %G7E)
o Gor vie+8 IB'7E%0 OG
7ri,,er event8 IB'E)71 UP0%7E1 O) 0ELE7E
7able na!e8 On table1 vie+
7ri,,er 7(e8 )o+ or state!ent
=*en clause8 )estrictin, condition
7ri,,er bod(8 PL.':L bloc-
T5e&ore tri,,ersU execute t*e tri,,er bod( be&ore t*e tri,,erin, 06L event on a table/
7*ese are &re3uentl( used to deter!ine +*et*er t*at tri,,erin, state!ent s*ould be
SPHOORTHY Engineering College
28
Department of MCA DBMS Lab Manual
allo+ed to co!lete/ 7*is situation enables (ou to eli!inate unnecessar( rocessin, o&
t*e tri,,erin, state!ent and it eventual rollbac- in cases +*ere an excetion is raised in
t*e tri,,erin, action/
T%&ter tri,,ersU are used +*en t*e tri,,erin, state!ent is to be co!leted be&ore t*e
tri,,erin, action and to er&or! a di&&erent action on t*e sa!e tri,,erin, state!ent i& a
5EGO)E tri,,er is alread( resent/
TInstead o& 7ri,,ersU are used to rovide a transarent +a( o& !odi&(in, vie+s t*at
cannot be !odi&ied directl( t*rou,* ':L 06L state!ents because t*e vie+ is not
in*erentl( !odi&iable/ 9ou can +rite IB'E)71 UP0%7E1 and 0ELE7E state!ents a,ainst t*e
vie+/ 7*e IB'7E%0 OG tri,,er +or-s invisibl( in t*e bac-,round er&or!in, t*e action
coded in t*e tri,,er bod( directl( on t*e underl(in, tables/
7ri,,erin, user events8
o IB'E)7
o UP0%7E
o 0ELE7E
7ri,,er ?o!onents8
o 'tate!ent8 7*e tri,,er bod( executes once &or t*e tri,,erin, event/ 7*is is t*e
de&ault/ % state!ent tri,,er &ires once1 even i& no ro+s are a&&ected at all/
o )o+8 7*e tri,,er bod( executes once &or eac* ro+ a&&ected b( t*e tri,,erin, event/
% ro+ tri,,er is not executed i& t*e tri,,erin, event a&&ects no ro+s/
7ri,,er 5od(8
7*e tri,,er bod( is a PL.':L bloc- or a call to a rocedure/
'(ntax8
?)E%7E IO) )EPL%?EJ 7)IEEE) tri,,erLna!e
7i!in,
Event1 IO) event2 O) event3J
OB tableLna!e
7ri,,erLbod(
E*peri$ent ,,:
Proble! 'tate!ent8
0e&ine a cursor +*ic* runs t*rou,* all e!lo(ees +*o belon, to deart!ent +it* id N 2/
'olution8
1/ Use 0eclare cursor s(ntax +it*in t*e PL.':L bloc- to de&ine t*e cursor +it* a si!le
3uer( +*ic* is select &ro! +*ere usin, e!lo(ee table and a condition deart!entLid N 2
SPHOORTHY Engineering College
29
Department of MCA DBMS Lab Manual
E*peri$ent ,-:
Proble! 'tate!ent8
0eclare a cursor +*ic* runs t*rou,* all e!lo(ees +*o belon, to deart!ent +it* id N 21
oen t*e cursor and close t*e cursor +it*out doin, an(t*in,/
'olution8
1/ Use oen and close oerations on cursors/ 7*is is si!ilar to oenin, and closin, &ile
*andles/
E*peri$ent ,.:
Proble! 'tate!ent8
0eclare a cursor +*ic* runs t*rou,* all e!lo(ees +*o belon, to deart!ent +it* id N 21
oen t*e cursor and &etc*es one e!lo(ee at a ti!e1 rints t*e last na!e and t*en closes
t*e cursor a&ter all e!lo(ees are done/
'olution8
1/ 0eclare cursor/
2/ Oen t*e cursor/
3/ In a loo1 &etc* eac* ro+ o& a cursor into a variable/
4/ Print t*e variable/
5/ ?ontinue t*e loo till t*ere are no !ore ro+s/
#/ ?lose t*e cursor/
E*peri$ent ,/:
Proble! 'tate!ent8
Use a cursor to loo- at eac* e!lo(ee +*o belon,s to deart!ent +it* id 1"1 c*ec- t*e
job ,rade and aend BE=L to all jobL,rades/
'olution8
1/ Use t*e =>E)E ?U))EB7 to identi&( t*e currentl( &etc*ed ro+ &ro! cursor and run
t*e udate 3uer(/
2/ 7*is is use&ul &or udate and deletes/
E*peri$ent ,0:
Proble! 'tate!ent8
?reate a tri,,er +*ic* +rites a record called Te!lo(ees table bein, c*an,edU +it* ti!e
in a lo, table +*enever an(one atte!ts to c*an,e e!lo(ees table/
'olution8
SPHOORTHY Engineering College
30
Department of MCA DBMS Lab Manual
1/ =e +ant to +rite a state!ent tri,,er t*at records t*e &act t*at so!eone is c*an,in,
t*e e!lo(ees table in a lo, table usin, be&ore tri,,er/
E*peri$ent ,1:
Proble! 'tate!ent8
?reate a tri,,er +*ic* +rites a record called Te!lo(ees table *as been c*an,edU +it*
ti!e in a lo, table +*enever so!eone success&ull( c*an,es t*e e!lo(ee table/
'olution8
1/ =e +ant to +rite a state!ent tri,,er t*at records t*e &act t*at so!eCone c*an,ed t*e
e!lo(ees table in a lo, table usin, a&ter tri,,er t*at acts on insert1 udate and delete
oerations/
E*peri$ent ,2:
Proble! 'tate!ent8
I!le!ent a solution t*at +ould record all atte!ted udates on salar( in t*e e!lo(ee
table alon, +it* t*e e!lo(ee id1 old salar(1 ne+ salar( and t*e ti!e +*en it +as
atte!ted in anot*er table/
'olution8
1/ Use ro+ be&ore tri,,er in udate oeration/
E*peri$ent -4:
Proble! 'tate!ent8
I!le!ent a solution t*at +ould record all udates on salar( in t*e e!lo(ee table alon,
+it* t*e e!lo(ee id1 old salar(1 ne+ salar( and t*e ti!e +*en it +as udated in anot*er
table/
'olution8
1/ Use ro+ a&ter tri,,er in udate oeration/
E*peri$ent -3:
Proble! 'tate!ent8
I!le!ent a solution to insert a lo, entr( in lo, table +*enever salar( o& e!lo(ees +it*
!ore t*an 2"""" is revised/
'olution8
SPHOORTHY Engineering College
31
Department of MCA DBMS Lab Manual
1/ =rite a ro+ a&ter tri,,er on e!lo(ee record/
2/ 7*e tri,,er s*ould +or- on t*e condition t*at t*e salar( o& t*e record is ,reater
t*an 2""""/
E*peri$ent -+:
Proble! 'tate!ent8
I!le!ent a solution +*ic* +ould transarentl( !a-e t*e user &eel li-e *e is udatin, a
vie+ but in realit( t*e vie+ is readConl( and a tri,,er is udatin, t*e base tables based on
t*e vie+ udate ,iven b( user/
'olution8
1/ Use t*e instead o& otion in tri,,ers to !a-e tri,,er +or- in lace o& vie+ and
reroduce t*e e&&ect intended/
Unit III Additiona' E*erci(e(
8/ =rite a cursor +*ic* ta-es ara!eters and invo-e a cursor &ro! +it*in a PL.':L
bloc-/
$/ =rite an a&ter tri,,er +*ic* acts at a ro+ level on insert.udate.delete and
trans&er old data to an audit trail table/


SPHOORTHY Engineering College
32
Department of MCA DBMS Lab Manual
Supp'e$entar5 E*erci(e(
1/ 0esi,n a database &or librar( !ana,e!ent in t*e colle,e1 oulate data and +rite
3ueries to return in&or!ation li-e boo-s issued1 boo-s issued to user1 nu!ber o&
boo-s issued1 boo-s reserved1 etc/
2/ 0esi,n a database &or &ee !ana,e!ent in t*e colle,e1 oulatin, data on &ee
a(!ents1 &ee receits and +ritin, 3uer(in, to return data li-e uncollected &ees1
+*ic* aid &ee1 etc/
6e7erence(
=ebC'ites8
+++/otn/oracle/co!
SPHOORTHY Engineering College
33
Department of MCA DBMS Lab Manual
5oo-s8
1/ 0atabase 6ana,e!ent '(ste!s1 Hort* @ 'ud*ars*an/
2/ 0atabase 6ana,e!ent '(ste!s1 )a,*ura! Hris*nan/
3/ 0atabase 6ana,e!ent '(ste!s1 El!asri @ Bavat*e/
SPHOORTHY Engineering College
34

You might also like