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

dbms 4th unit

The document discusses SQL cursors, including implicit and explicit types, and their role in processing data within a database. It outlines the syntax for creating and managing stored procedures and triggers, emphasizing their use in handling events like inserts, updates, and deletes. Additionally, it covers the importance of maintaining data integrity and provides examples of SQL commands and procedures.

Uploaded by

divyapriya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

dbms 4th unit

The document discusses SQL cursors, including implicit and explicit types, and their role in processing data within a database. It outlines the syntax for creating and managing stored procedures and triggers, emphasizing their use in handling events like inserts, updates, and deletes. Additionally, it covers the importance of maintaining data integrity and provides examples of SQL commands and procedures.

Uploaded by

divyapriya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

to ths tonte

CsorS - A cwsa t's a pofnten


an
ana i-e. he. memory oua hor proceing
hbormatior needed
Contoung all e :
SGL Shm4 ohich
tor procening the sm
A tumtosn holds fhe raws retuned by a
LUwsOr holds is
SQL Stm ho Sef of rows he
rederred b ay vhe achye se .
Thee ae 9 hype o twu ors
1Smplicil twuor
9. Euplick CwjD
oreate
mplicit twuor Thee alu automatally
exeeu/
whinwer Cn SQL SBmB s
by oracle the st
éphcu cusor or
When fne is no
L wior
Lunov
cannot Lonol mpliciF
program mes
ISsuod an mplicit
pmL Stmt s
heneve opeathon
is Strmt Por îndent
cwociated with
Cor s nedi
nsenked.
to be insenhed
data thaf need
ho ds he tho iden tifie
lursor identie
the twsoY luwu o r
Hhe operahionu
tho
deleBe
for update & fected
aftectesl
uould
be
thaf
the Tous Ccosor
is he implictt
n PIsqL SL cus or sop)n
/tound, 1.
athibute Such a
which aluoay hos
. rowcount
J.Not Found

rehon u e
i on insell, updafe or

-dound ne or more rou


altecled
delele Sfrmt more rnu
rehun d oo tr
Shnt
Or selecf
otbreruotse fale

Nodtound--tMe logical oppotle


Ppotile of ourd
foud rehnna hue a n iwe
seled rehuns ho 1on eed
update delete pr
4
Othewise dake
uso
-aloays tehwns take br Imiplied
38 open rsor
qubmaicl
close e SL
because oracle
eleceuhng is SQL d .
Ofte
rous affezte
numbes
YOwIoun}yehsns tue
ypdore
bi delete Shn
inuesl,
6y a n

Syntaz
Sql.atfobule_ram@e
Cistome
tob/p
n (ons iden

he able & increase the


increa4e the
Proqram to uplate
twhomey.

Soo. pr all
Salom
Salay by
Declore
rptal_vous numbes(A

begio
updote tutlome

+500
Se Sabuy Salay
S2e.notlord then

uwhmey seleetl),
dbm -0upuB pul_ line(ho
ELutf Sqlo u r fhen
tofal-rouOS SqL Y, TOwOunt
vos ) cunes the
dhms-0utpuk-Pufhne(tolal
endf
end

6tuhmex selected
HsL procedturk Suttentullycompled

upliciB cunsod mmey hr galniG


dehined by proqro
Thue are
Conieaf a
ara
a
2 deined
c onlet
he
more
conol oven a
selech
creales o n
sechon , 2/
derleraion
In the one
row
than
more
Smt which rehun

Syntak selech- Stmk


ctuuorname
s
CUsor

bollowr
voNks cu
cuNBor
Euplicit
ihe memon,
Declon ing-jinihali3e
allccahe he memo'y
ope ing
Petching refievin fue da/s
memDYy
ctoing releou h e allocaredd

Dele Qeclasing te Cunsdr

Cubb Ccwbme
Select id, name p tusfome
0pening he tu8 O
Open CCuAbmeM
efchi f uuio c_acdar
C_a,
Fekch tLAD mEM tntd (:d,
(0
closng the tunlor
clos e -tuktomes

deelane
cd cusmmey. ld4. tpe
C-name tnomes ome . type
addi LLbme renl type
Csor CCsdomers is
Selec d nume addres
bom (tuomCrp
Begin
OpeniCCtyhomeu

loop
Petch LuwhomeY iHO C-*d ,Cnqme, c-atH
9
Sut when etybmeu notfoum
dbmeputput pul lina ( a ' l t n a n e

Snd loop
e-adr)
cloe e-Lusho meM

Vames3b Ahme da bad


2 Khilan de lhi
3 hhounhlk Fotq
mumba
Triggeu
g9e of sGL stmis sored in thu dh
a sel
Cal bg. A sGL tnggen is exeteuted or tired ibenwg
an event anoiated with a table o r s

inses, updake or delekte


caht
1 called dicentlg aubmah cally
modikcahon evend is made againuf a
dala
Hab te

Aduanteue
alteiratve acy fo
SQL nggess provice an
Cherk int egrity
oi do
can cateh
emd
io
SQL mgges
D r e v e n t nualid. bontathòny

TEaher
authona
poude seciiy
Prowid e event toggjing shoning ntormoban
On table

Synta1

treate or repla ceJ togsen tiggen-neme


Beforel aften/ niead of?
TNne lo] lupdade Lor delee
Cod col-na mej
on table- Name

Refeenting obl a o neo a n


hor each mw]
when lriihon)

Deelan
Detlasahon.s

Bin
etutable Smif
Stephop
Ccephcnhondng-
end
reateor repkce]mggen iagename
enfe or replace an evishing m9ge3 sih

mce.name } wed in Lreahon


of views
Eehreaienl înahead of
will be exerut
Specihe when te foigg e
er Delete Cor] l ypdele y-
Dethe omL cpeahin
) of col nanme7- Specihes eonome that uwll be upiakes
of he able
Specihes the
nanme
able_Dame]
apociatd with the iggen
Refeuncing old as o neoas n
ahew & old valu hr vaia
DML
efen
Allows üs

or each rous Speciheso row-level biggen


condihon or rows or whIth
a
provides
cohen Ccondihon)-
bire.
the nggei would

replace doigges display.Sealary -chaqe


creat or
tusbmey
insent or updale on
8eore delete o r
r each ioud

when (n ewijd >o)


Decto
SalditP numbe

Begin new.Salany od.Saloany


=
Sclt_diff
dbmtoutput.put line('oldsalany:':od.salany)
dbm0ufpu pu-line ( heco Salony:|: neo.Sa lanp

bmoulput puB.linel'nloyoff:"I: sal_dift)


end
date
"nges create
Note
0d nol qvalable lor lableka
& new referen ce au

iggers
9 P you want b quey the table in
he Same
niggea
n19G
hen you sheub use fie akes bigger

age, adaren salar


insenf înb Cid
uwhnasDam,
1 *3, hp, 7500.00)
valuu l7, KriH',
deplay-salkly-a vl
&ecord creca hed the toiggej
will be Ared.

old SolaM
new salay: 1500
salmy diF Festpce
tue aboue reuk
o solony is not aveulable ,
Co mes null

2 updale tusbmeAS
tSoo
Sel solay Sealoy
whu 2
ob salay :[Sod
nU Salay 12000
Salar ditterun e
Sto red protedr (0
s0
ave he tode
s h r a s protedule
is wed b
call
an be eued
oves &Due) ogaina
hal it
proteduru t execute
the sbred
Sored
paamele y o a
Cwe can
alyo pon

procedne

Syntax:
precedur procedul -Nome
Create

Sql-Stm

Snecuhe a shor proredune

Euec procedure_Name

crecle proceduL &elechalltturymey

Seleck o m tuwtomely

Sec selectalltushmev
Sored proLedunl tolth ore Parametaa
Create pro doL Seleekall ccuromey dy vasuhast)
A 3

Seleck hom tubme, Ahere cihj : 6 cn

enec selech alltusbhmels, cih> Jhagkhand

You might also like