0% found this document useful (0 votes)
20 views7 pages

DBMS Assignment 4

DBMS assignment on chapter-4 Database management system 2 year/3 sem/k- scheme Computer Engineering MSBTE
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)
20 views7 pages

DBMS Assignment 4

DBMS assignment on chapter-4 Database management system 2 year/3 sem/k- scheme Computer Engineering MSBTE
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/ 7

NAME: Assignment No 4

STD.: DIV.:
DATE:
PAGE:

1Oerîne CursoL. Enlist the types of Cusong and explain'uoith. ier

examplk
AnsPU/Ss CuKSDL fs a pcioikathat pointg to the TeAult 8et Dthe. at

SQL queny against database table


fochi Colum value îs poiokd using ponts-We can independtly
lmonipulahe CuAY Values. S

ACuHA0r f3a mechon'sm bs Lohich ue Can assin anameto a'SEIEE


|8tatement" and manpulake the inlpamation. and bèncethe xeAult
ts diaplauued. a

There oYe tuoo kinds of ur9Or:


Impliit Cursor
2.Explicit msom
lxImpliit Cusor
These QHe Cueated by dejautt ohen DML Statements (ihe INSERT,
UPDATE, Ond DEIETE Qtotements oHe executed They aHe also
Created when a SEIECT Statermert that rekins ~ust one to0
fs executed.
The SQl cursor attributes aHe:
%RowcOUNT:THe number DÂ rOLOS pocessed bya SQL Statement
"lo FoUNo:True if atleast one How oas processed
"lo NOT EDUND :Tue f no DOs tu4epMce3Sed
been
" SOPEN True ff Cusom 0S open oT false îf CusOL has
not opened or has been Closed

For Educational Use


WORLD STAR
STD.: DIV.: DATE:
PAGE:
For Examplei A
toble pnram to.print Numbes of muos
deleked frmEMP
DECLARE
RoLDEL
BeGIN
NumbeH;
DELETE CROHEmps
RDWDEL: = SQL' ROWCOUNT,
DBMS. OUTPUT. PUT |INE
Row_DEL, CNo-DPoLOS deleted arl
END:
Explidt CusTS
JE SelectShotermens in PL/SsQL returns Muliple DUS then ue
Creakk an explicit Cursor. haueto
The Set DÊ HOLS Kekunned by A
1eSult set.Is Sizc is the numben DÊmulti-m Quexs fs called the.
ADuS that meet the 8eau(b
uiksa.
Syotox c£Rplicit Csor:
CURSOR Cursor Name IS S&L SELECT Statement,
Explicit ut sor Can be. Caoirolled usiog 4ollouingshuce Contnl
StatemenIs
OPEC: Opan Statement idenifesA the acfue Set.ie qiex4
Tehuned by Select Statemént
FETCH; fetch Statement 4ekches ADLOS into the vaxiabBea.CunsmS
Can be mocde fnto use usig Qssox Por Aoop 4fetch Shatement
CLOSE: Close Statement clbges the usA09.
WORLD STAR For Educational Use
DIV.: PAGE :

foL Exanmple
Prqnam tor accessinq the ows using utor

DECLARE Cusscr. L Sta

atio

CuRSOB_ C1 is Select RON ENP, iecia

St empno EM..
Sr ename EmpNo'% ype: blo
ine

FMP.lastNamele
Sr ob FMP.Tob tupe;
SEr mqm EMP.Mqr'letype
biype, ies a

SEr hirdate EMP


Hidate
Str SalEMP. Sal'%hype kkypei (Max
Str deptno hara

YDO Dumbeui EMP.DeptNO %Hype


BEGIN Char

fOR erec INC1


Pre
IF o
mwCount =roo THEN
DBMS DUTPUT.PUT INE (SH empno"lstr
Sr birdake || enames
S+ Sal str dept
END IE;
END LDDP.
END,

WCRLD STAR For Educational Use


NAN

aDzscribe txteptBon handling în PL/saL


-An excepon is an eHHOY SÍtuacn,tohich aises. dueég
pogram execuHonwhen an eYAOY OCCUHS exceptfoo is raised,
norma executon is SBopped and Coorol transers to executon
to Pxceptan- hoodlinq paut.
-Exception handlexs aue routioes onitten to handle the exception.
PL/s&LPDvides a featuse to hondlethe exception obich oCCwt
ioo pL/SQL Block nsuon as exceptioo handtin ha
siog excepticn handling te Can test the Code and auo)d itjmm
exiing unexpeckedls when an exCeptioo ocLHS a mes 3042..
which exploYns irs Cause is receiued.
The Ssnt0x 4m odding the excepton ia given belouwr
DECIARE
Decdaxaton Section
BEGIN
Excepfon Section
ExCEPTIDN
WHEN ex nomei THÊN
-Eony hordiípg Statements
WHEN ex_name2 THEN
-fror handlfog StotementS
WHÊN COHh ers THEN
-Emrox handlig 8hatements
END

WORLD STAR For Educational Use


Dunbe.

DECACE

BEGN

dbgoutput put lineCGreat eot nuobet la'lo).


ISE I b>a AnD b>CTHEN
dhos output putline Greatest uroen fel6),
dbros.output put_line ('artarest huroben fe'll),
[ND If,
END,

QExplain use of datobase Tifggers-Wiite a Synlax to bueate. arnd


deleke irigge.
Ara Uciog dalabae Tiiggexsi
-Dala fs qenenaked bn is oon
2 Replicate Iable Can be rnaîntaiped.
3To enyoxce Cornplex înt cqrity Contraipls.
4. To edît data modificalions.
6. To auto încrement a eld

For EduCatlonal Uso


WRLD STAR
DATE :
NAME:
STD.: DIV.: PAGE:

yotax for reating tiggerîa qrtn belouw:.


CREATE OR REPLACE) TRIGGER triqgexname
CBEfOREAETER LINSIEAD OEI
CNSERT PDATE DELETE
LoN Lablename. foR EACH STATE MÊNT/fOor each ouo WHEN
Condiion
Suptax to delete a triggen,Ne U3e DROP TRIGGER Command.
DROP TRIGGER tiqqeH_name

0.5Explain proceduse. fo PL/SAL oith example.


Ans ASEored pDceduxe. or îo simple oa proc. fs a named PL/saLbloc.
ohich perjorma DnR OX MOYe &pecift toah.thk fs 8imilas to a
proedue fo othex poqrammioq lonquaqea
Siored pMcedusea offex advankaqes fnthe aueas of
deutlopnient
Allocation. ,nkeqaity.- Secuxityipexcoxmant,aDd mémny
The paDcedunes a4e Stored în the databases and
executed onthe database geHVeH LObich fs tikels to ane_thexeloe
more pouieul
than the clients.
The Code.fs gtored în pre-conmpiled4om ohich meansthatit is
Syntochically valid and does not neco'to be. Conmpiled atqu-tine,
Hherehs Sauing resoUHCeA.
ach useN O ihe. SBored procedune toill UAe eaeathy the Same form of
Lqueufes uohich means the quexs QHe Heused by redudog the
parsing Dvethead and frmprnving the Scalabiliy of agplicoions.
For Educational Use
WORLD STAR
NAME:
STD.: Statement Executor
DIV. DATE:
As tbe PAGE:
paDceduses atestored
ronse the Code,
anyeu intumediake lomthe clientsin1heothe databasethentisn noncedto
the dalabases e
SeUeL to the oro cienrs.
S6xplain blbc Struche oE PL/8.
) a lsa
ne 8al ods.a block-
PL/SSL Situcued
&tatementSlanguoget
The hasicathunit
Aset O toqically relaed 8atement& AoxMaPuSoLoanam
.A PL/SL bloch Ynp ssLs Cons'grs 4
Conists Of thaee Sectons: a blbck. oblock.
4.Keuuord
Declaraion SecHon: The declasaHon Recion
MOuiables OECIAPEThi s Secionis bplional and
staxt3.
fs uwin the
usedto declave
l.Fxecutfop ,ConstanSrecoTds
BEGIN and ends
and QursorS.
SecionThe txecuton Secon SBaxts uin
uufth END This is a he Keuuonrc
Cormpulsong(PKe Becsfon The
poqram Logic YS uiHen heae. The Constucis
&tatement and BQL SBatements_ aHe
LOntenhee. loops..C onat songl
.Exeeutiop
the Keuuonrd Exceptivn Secioni The Exception Sechion sBaxlS uwith
loe bandled PxCEPTIDN and fs opfonal.Anuy HMDHS Înthe poaxam
fn ths &ecion.
foL Example DECLARE
/Dec)auaive Secion; aíable,types, and
Local Subprograma."1
BEGIN
Executa ble &echion procedural and sqL&Batements c
here.
This ia the only blek. &echion of the block ia.
reQufred./
For Educational Use
WCRLD STAR

You might also like