Sunteți pe pagina 1din 18

# ACADEMIA DE STUDII ECONOMICE FACULTATEA DE CIBERNETIC, STATISTIC I INFORMATIC ECONOMIC

PROIECT SGBD

## 1. Defini e! "#\$e%ei &!'ei (e (!)e

)n *a+a de da&e ,e -or re.(,i da&e"e \$o"o,i&e /n .e,&iunea aderarii "a \$onduri"or de pen,ii pri-a&e o*"i.a&orii pi"onu" II0 fondul de pensii, angajati, participanti, adeziuni, reclamatii 1 S'2e%a &!'ei (e (!)e ara&( /n \$e"u" ur%(&or 0

## pro%p& Se 'reea+a noi"e &a*e"e4

Crearea &a*e"ei FONDULDEPENSIICREATE TABLE fonduldepensii (codfond number(3) CONSTRAINT PKe !fonde PRI"AR# KE#\$ denumire %&rc'&r((()) NOT N*LL \$ direc+or %&rc'&r((())\$ nr!&n,&-&+i number(.)\$ /on& %&rc'&r((()))0

## Crearea &a*e"ei ANGA.ATI 0

CREATE TABLE &n,&-&+i (cod&n, number(3) CONSTRAINT PKe !&n,&-&+i PRI"AR# KE#\$ nume %&rc'&r((1)) NOT N*LL \$ prenume %&rc'&r((1)) NOT N*LL\$ CNP number(13) \$ func+ie %&rc'&r((12)\$ codfond number(3)\$ &dres& %&rc'&r((32)\$ CONSTRAINT 3Kcodfond 3OREI4N KE# (codfond) RE3ERENCES fonduldepensii(codfond))0

## Crearea &a*e"ei PARTICIPANTI0

CREATE TABLE p&r+icip&n+i ('odpar&i'ipan& nu%*er5!6 CONSTRAINT 78e9:par&i'ipan&i 7RIMAR; <E;, nrade+ nu%*er5 6, prenu%e -ar'2ar#51!6, CN7 nu%*er51 6, 'odan. nu%*er5 6, &e"e\$on nu%*er5106, CONSTRAINT F8ade+ FOREIGN <E; 5nrade+6 REFERENCES ade+iuni5nrade+6,

## CONSTRAINT F8an. FOREIGN <E; 5'odan.6 REFERENCES an.a=a&i5'odan.66 1

CREATE TABLE &de/iuni (nrade+ nu%*er5 6 CONSTRAINT

7<e9:ade+iuni 7RIMAR; <E;, da&aade+ da&e, 'o%i,ion nu%*er5!6,'od\$ond nu%*er5 6, CONSTRAINT F<\$ond FOREIGN <E; 5'od\$ond6 REFERENCES \$ondu"depen,ii 5'od\$ond661

Crearea &a*e"ei RECLAMATIICREATE TABLE recl&m&+ii (codrecl&m&+ie number(5) CONSTRAINT PKe !recl&m&+ie PRI"AR# KE#\$ nr&de/ number(3) NOT N*LL\$ mo+i% 6ARC7AR(((2)\$ CONSTRAINT 3Ke nr&de/iune 3OREI4N KE#(nr&de/) RE3ERENCES &de/iuni(nr&de/))0

/. P,01+! e! )!&e+e+,

7opu"area &a*e"ei FONDULDEPENSII INSERT INTO fonduldepensii INSERT INTO fonduldepensii INSERT INTO fonduldepensii INSERT INTO fonduldepensii 4EOR4E8\$8;28\$8SIBI*8)0 INSERT INTO fonduldepensii >58\$8B*C*RESTI8)0 INSERT INTO fonduldepensii INSERT INTO fonduldepensii ANA8\$8:28\$8PLOIESTI8)0 INSERT INTO fonduldepensii CATALIN8\$8.)8\$8PITESTI8)0 INSERT INTO fonduldepensii INSERT INTO fonduldepensii E*4EN8\$8;28\$8TI"ISOARA8)0 6AL*ES 6AL*ES 6AL*ES 6AL*ES (818\$8IN48\$8IONESC* AN9REI8\$ 81228\$8IASI8)0 (8(8\$8AI48\$84ALCA CLA*9I*8\$8:;8\$8CL*<8)0 (838\$8BCR8\$8PALC* "ARIA8\$8:58\$8ORA9EA8)0 (8.8\$86ITAL8\$89*"ITRI*

6AL*ES (8)8\$8=EPTER8\$8"ARICI* ION8\$8 6AL*ES (858\$8A6I6A8\$8NICA 4ABRIEL8\$8;.8\$8IASI8)0 6AL*ES (8>8\$84ENERALI 8\$847E*CA 6AL*ES (8:8\$8INTERA"ERICAN8\$89ACI* 6AL*ES (8;8\$8PRI"A PENSIE8 \$86ELISC*8\$8>(8\$8IASI8)0 6AL*ES (8128\$8BR98\$8LE3TER

## 7opu"area &a*e"ei ANGA.ATI 0

INSERT INTO &n,&-&+i 6AL*ES (82218\$8"I7ALAC7E8\$8AN9REI8\$81:31(2.)5>:;28\$ 8CONS*LTANT8\$8(8\$8 Bucures+i \$Bd? T'eodor P&ll&d 8)0

INSERT INTO &n,&-&+i 6AL*ES (822(8\$8"I7ALAC7E8\$89AN8\$81>)2.231(>53.8\$8CONS*LTANT8\$818\$8 Bucures+i\$ Bd? Timiso&r& 8 )0 INSERT INTO &n,&-&+i 6AL*ES (82238\$8CRISTESC*8\$8"I7AI8\$81:22;1(;21(5>8\$ 8CONS*LTANT8\$ 838\$8 Bucures+i \$Bd? 4'? "&,'eru8)0 INSERT INTO &n,&-&+i 6AL*ES (822.8\$86AR9AR8\$84ABRIEL8\$81:1111(.)5>;:8\$8CONS*LTANT8\$858\$8 Bucures+i \$S+r? 9o&mnei 8)0 INSERT INTO &n,&-&+i 6AL*ES (822)8\$8LI=ESC*8\$8NINETA8\$8(>)2)1>;2(3.18\$ 8CONS*LTANT8\$8>8\$8 Bucures+i\$ Bd? 4eor,e Cosbuc 8)0

INSERT INTO &de/iuni 6AL*ES (81(38\$TO!9ATE(81(@21@(22:8\$8dd@mm@ 8)\$ 8>28\$858)0 INSERT INTO &de/iuni 6AL*ES (81(.8\$TO!9ATE(812@21@(22:8\$8dd@mm@ 8)\$ 8>28\$8(8)0 INSERT INTO &de/iuni 6AL*ES (81()8\$TO!9ATE(82.@21@(22:8\$8dd@mm@ 8)\$ 8>28\$ 818)0 INSERT INTO &de/iuni 6AL*ES (81(58\$TO!9ATE(81.@21@(22:8\$8dd@mm@ 8)\$ 8>28\$838)0 INSERT INTO &de/iuni 6AL*ES (81(>8\$TO!9ATE(81(@21@(22:8\$8dd@mm@ 8)\$ 8>28\$818)0 INSERT INTO &de/iuni 6AL*ES (81(:8\$TO!9ATE(81.@21@(22:8\$8dd@mm@ 8)\$ 8>28\$8(8)0 INSERT INTO &de/iuni 6AL*ES (81(;8\$TO!9ATE(81(@21@(22:8\$8dd@mm@ 8)\$ 8>28\$8>8)0 INSERT INTO &de/iuni 6AL*ES (81328\$TO!9ATE(81.@21@(22:8\$8dd@mm@ 8)\$ 8>28\$818)0 INSERT INTO &de/iuni 6AL*ES (81318\$TO!9ATE(811@21@(22:8\$8dd@mm@ 8)\$ 8>28\$838)0

7opu"area &a*e"ei PARTICIPANTI INSERT INTO p&r+icip&n+i 6AL*ES (82218\$81(38\$8Pe+re8\$81>3112;1;>(3.8\$822.8\$82>.(3.)>5(8)0 INSERT INTO p&r+icip&n+i 6AL*ES (822(8\$81(.8\$8"i'&el&8\$8(>:12251(5)>:8\$82218\$82>():>;21(8)0 INSERT INTO p&r+icip&n+i 6AL*ES (82238\$81()8\$8Io&n&8\$8(:21(15;21(>58\$822(8\$82>);1(:>;28)0 INSERT INTO p&r+icip&n+i 6AL*ES (822.8\$81(58\$8"&ri&8\$8(>;252>(3>5:;8\$82238\$82>5;::;21(8)0 INSERT INTO p&r+icip&n+i 6AL*ES (822)8\$81(>8\$8Sil%i&8\$8(:32:13;2>:)58\$822(8\$82>..;)5:>18)0 INSERT INTO p&r+icip&n+i 6AL*ES (82258\$81(:8\$8Ion8\$81:2232>>:(3.18\$82218\$82>((.11>5;8)0 INSERT INTO p&r+icip&n+i 6AL*ES (822>8\$81(;8\$84eor,i&n&8\$8(>:122;1(;:5)8\$822)8\$82>:;21(3..8)0 INSERT INTO p&r+icip&n+i 6AL*ES (822:8\$81328\$8Tudor8\$81:)11(15>:(318\$822(8\$82>(13.>:;18)0 INSERT INTO p&r+icip&n+i 6AL*ES (822;8\$81318\$8"i'&i8\$81:12;1211.3)58\$82238\$82>..)5>:1(8)0

## 7opu"area &a*e"ei RECLAMATII0

INSERT INTO recl&m&+ii 6AL*ES (8111(((8\$81(.8\$8Nu &p&re inre,is+r&+8)0 INSERT INTO recl&m&+ii 6AL*ES (8111(3(8\$81(:8\$8A eApir&+ bule+inul8)0 INSERT INTO recl&m&+ii 6AL*ES (81;;;((8\$81328\$8Nu es+e &n,&-&+8)0

B. INTERACTIUNEA

CU

SERVERUL

ORACLE

PRIN

## INTERMEDIUL COMEZILOR S2L 3LDD SI LMD4.

13Sa ,e i%p"e%en&e+e o noua &a*e"a,nu%i&a RE7RE>ENTANTI , 'are ,a 'on&ina 'a%puri"e nu%e,prenu%e ,i CN7 dupa a'eia,i ,&ru'&ura 'u &a*e"a ANGA?ATI de\$ini&a an&erior,\$ara ,a 'on&ina ,i inre.i,&rari"e din a'ea,&a,\$o"o,ind 'o%en+i LDD1 ,e& ,er-erou&pu& on *e.in
eAecu+e immedi&+e 8CREATE +&ble REPRE=ENTANTI &s selec+ nume\$prenume\$ cnp from AN4A<ATI B'ere 1C(80

end1 @ #3Sa ,e adau.e in &a*e"a RE7RE>ENTANTI ,un nou an.a=a& pre"ua& din &a*e"a ANGA?ATI, punanduA,e 'ondi&ia ,a ,e ,e"e'&e+e an.a=a&u" 'are are 'odu" ,\$o"o,ind 'o%en+i LMD 3Sa ,e a\$i,e+e 'a ,Aa adau.a&3 de'"are -:nu%e an.a=a&i3nu%eB&9pe1 -:prenu%e an.a=a&i3prenu%eB&9pe1 -:'np an.a=a&i3'npB&9pe1 *e.in ,e"e'& nu%e,prenu%e,'np in&o -:nu%e,-:prenu%e,-:'np \$ro% an.a=a&i C2ere 'odan.D 1 in,er& in&o RE7RE>ENTANTI 5nu%e,prenu%e,CN76 -a"ue, 5-:nu%e,-:prenu%e,-:'np61 d*%,:ou&pu&3pu&:"ine58SD& &d&u,&+ in +&bel& REPRE=ENTANTI &n,&-&+ul cu
numele E 8FF%!numeFF8 prenumele %!cnp)0 8FF%!prenumeFF8 si cnpDul 8FF

end1
@

3Sa ,e %are,'a 'o%i,ionu" 'u !0 pen&ru ade+iuni"e 'are apar&in de ING3 de'"are -a" ade+iuni3'o%i,ionB&9pe0D!01 *e.in upda&e ade+iuni ,e& 'o%i,ionD'o%i,ionE-a" C2ere 5,e"e'& 'od\$ond \$ro% \$ondu"depen,ii C2ere denu%ireD8IN48)C&de/iuni?codfond0
end0 @ selec+ G from &de/iuni0

F3Sa ,e ,&ear.a &a*e"a Repre+en&an&i1 *e.in eGe'u&e i%%edia&e 89ROP +&ble REPRE=ENTANTI 80
end0 @

!3Sa ,e de'"are o -aria*i"a in 'are ,a ,e re&ina nu%aru" de an.a=a&i ai \$ondu"ui de pen,ii AHIHA din &a*e"a \$ondu"depen,ii3 Sa ,e a\$i,e+e nu%aru" de an.a=a&i ,dupa 'are ,a ,e %i',ore+e 'u 10B ,i ,a ,e a\$i,e+e nou" nu%ar33 de'"are -:an. \$ondu"depen,ii3nr:an.a=a&iB&9pe1 *e.in ,e"e'& nr:an.a=a&i in&o -:an. \$ro% \$ondu"depen,ii C2ere denu%ireDIAHIHAI1 d*%,:ou&pu&3pu&:"ine58Num&rul de &n,&-&+i es+eE8FF%!&n,)0
%!&n,EC%!&n,G2?;0 end0 @

## d*%,:ou&pu&3pu&:"ine58Num&rul de &n,&-&+i es+eE8FF%!&n,)0

J3Sa ,e ,&ear.a din &a*e"a ANGA?ATI ,repre+en&an&u" a" 'arui 'od e,&e da& de "a &a,&a&ura1
SET SER6ERO*TP*T ON &ccep+ % promp+ 8In+roduce+i codul &n,&-&+ului pe c&re %re+i s&Dl s+er,e+iE 80 decl&re %!cod &n,&-&+i?cod&n,H+ pe0 be,in %!codCI%0 dele+e from &n,&-&+i B'ere cod&n,C%!cod0

## C.STRUCTURI REPETITIVE SI ALTERNATIVE.

13 Sa ,e a\$i,e+e prenu%e ,i nu%ar de &e"e\$on pen&ru par&i'ipan&u" 'are are 'odu" 00! ,i ,iAa "a,a& 'on&a'& in re&eaua oran.e ,i %e,a= in 'a+u" in 'are ,iAa "a,a& 'on&a'& in ori'are a"&a re&ea, \$o"o,ind &ipu" de da&a 'o%pu,3

SET SER6ERO*TP*T ON 9ecl&re T pe +ip is record ( %!prenume p&r+icip&n+i?prenumeH+ pe\$ %!+elefon p&r+icip&n+i?+elefonH+ pe)0 & +ip0

*e.in

selec+ prenume\$+elefon in+o & from p&r+icip&n+i B'ere codp&r+icip&n+C822)80 if &?%!+elefon liJe 82>.H8 +'en dbms!ou+pu+?pu+!line(8P&r+icip&n+ul 8FF&?%!prenumeFF8 &re num&rul de +elefon8FF &?%!+elefon)0

e",e d*%,!ou+pu+?pu+!line(8P&r+icip&n+ul
end if0 end0 @

## nu es+e in re+e&u& or&n,e8)0

*. Crea&i un *"o' 'e ,e"e'&ea+a 'odu" %aGi% a" unui \$ond de pen,ii3 Da'a 'odu" e,&e in in&er-a"u" K133#L ,a ,e a\$i,e+e denu%irea a'ea,&uia,da'a e,&e in&re KF3310L ,,a ,e a\$i,e+e dire'&oru",in re,& ,a ,e a\$i,e+e %e,a=1 SET SERHEROUT7UT ON DECLARE

-:'od \$ondu"depen,ii3'od\$ondB&9pe1 -:denu%ire \$ondu"depen,ii3denu%ireB&9pe1 -:dire'&or \$ondu"depen,ii3dire'&orB&9pe1 BEGIN SELECT %aG5'od\$ond6 in&o -:'od \$ro% \$ondu"depen,ii 1 SELECT denu%ire in&o -:denu%ire \$ro% \$ondu"depen,ii C2ere 'od\$ondD-:'od1 SELECT dire'&or in&o -:dire'&or \$ro% \$ondu"depen,ii C2ere 'od\$ondD-:'od1 CASE M2en -:'od *e&Ceen 1 and # &2en d*%,:ou&pu&3pu&:"ine5NDenu%irea \$ondu"ui de pen,ii e,&e0 NOO -:denu%ire61 C2en -:'od *e&Ceen F and 10 &2en d*%,:ou&pu&3pu&:"ine5NDire'&oru" \$ondu"ui de pen,ii e,&e0 NOO -:dire'&or61 e",e d*%,:ou&pu&3pu&:"ine5NHa1oarea %aGi%a nu ,e a\$"a in ni'iunu" din&re in&er-a"e"e indi'a&eN61 end 'a,e1 end1 @

3Sa ,e nu%ere 'a&e ade+iuni ,Aau \$a'u& "a \$ondu" de pen,ii ING,,&iind 'a 'odu" pen&ru a'e,& \$ond e,&e 13 ,e& ,er-erou&pu& on DECLARE
cursor c1 is selec+ coun+(nr&de/) num&r from &de/iuni B'ere codfondC10 %den fonduldepensii?denumireH+ pe0 nr number(12)0 selec+ denumire in+o %den from fonduldepensii B'ere codfondC10

## open '11 \$e&'2 '1 in&o nr1 '"o,e '11

dbms!ou+pu+?pu+!line(8l& fondul de pensii 8FF%denFF8 sD&u inre,is+r&+ 8FFnrFF8&de/iuniK)0 end0 @

## F3Modi\$i'area %o&i-u"ui pen&ru 'are ,Aau \$a'u& re'"a%a&ii3

9ECLARE %!mo+i% recl&m&+ii?mo+i%H+ pe0 %!nr&de/ recl&m&+ii?nr&de/H+ pe0 BE4IN SELECT mo+i% in+o %!mo+i% from recl&m&+ii B'ere codrecl&m&+ieC111>>>0 dbms!ou+pu+?pu+!line(8"o+i%ul ini+i&l es+eE 8FF%!mo+i%)0 I3 %!nr&de/ L (22 T7EN %!mo+i%EC8Nu siD& pl&+i+ +&Ae l& +imp80 ELSE %!mo+i%EC8Cnp ,resi+80 EN9 I30 dbms!ou+pu+?pu+!line(8"o+i%ul fin&l es+eE 8FF%!mo+i%)0 end0 @

D.TRATAREA E5CEPTIILOR.
1. Sa ,e a\$i,e+e nu%aru" ,i da&a pen&ru ade+iunea \$a'u&a "a GENERALI3Sa ,e &ra&e+e erori"e 'are po& aparea3 de'"are .:nu%ar &de/iuni?nr&de/H+ pe0 .:da&a &de/iuni?d&+&&de/H+ pe0 *e.in ,e"e'& nr&de/\$d&+&&de/ in+o ,!num&r\$,!d&+&
from &de/iuni\$fonduldepensii B'ere (selec+ denumire from fonduldepensii B'ere &de/iuni?codfondCfonduldepensii?codfond)C84ENERALI80 dbms!ou+pu+?pu+!line(8Adeiunile f&cu+e l& 4ENERALI &u num&rul E 8FF,!num&rFF8 si d&+& E8FF,!d&+&)0

## dbms!ou+pu+?pu+!line(8Nu eAis+& &de/iuni inc'ei&+e l& 4ENERALI8)0

C2en &oo:%an9:roC, &2en d*%, ou&pu&3pu&:"ine58Pre& mul+e r&nduri8)0 end1 @ #3Sa ,e adau.e in &a*e"a RECLAMATII in'a un &up"u3
SET SER6ERO*TP*T ON 9ecl&re e EMCEPTION0 Pr&,m& eAcep+ion!ini+(e\$D21.22)0

*e.in

## EPCE7TION M2en e &2en

9bms!ou+pu+?pu+!line(8A+en+ie? Nu &+i specific&+ codul &de/iunii8)0 9bms!ou+pu+? pu+!line(SNLERR")0 End1 @

3IneGi,&en&a unui anu%i& \$ond de pen,ii in *a+a de da&e5NO:DATA:FOUND63 DECLARE -:denu%ire HARCQAR#5#061 BEGIN SELECT denu%ire INTO -:denu%ire FROM \$ondu"depen,ii MQERE +onaDNORADEAN1 d*%,:ou&pu&3pu&:"ine5-:denu%ire61 EPCE7TION MQEN no:da&a:\$ound TQEN d*%,:ou&pu&3pu&:"ine5NNu eGi,&a a'e,& \$ond de pen,ii in *a+a de da&eRN61 END1 @ F3Hio"area unei re,&ri'&ii de in&e.ri&a&e A 'ap&area erorii ,&andard 'u nu%aru" S##T# DECLARE eG'ep&ie1 EPCE7TION1 7RAGMA EPCE7TION:INIT5eG'ep&ie1, A##T#61 BEGIN DELETE FROM 7ARTICI7ANTI1 EPCE7TION MQEN eG'ep&ie1 TQEN d*%,:ou&pu&3pu&:"ine5NNu pu&e&i ,&er.e par&i'ipan&u"N61 d*%,:ou&pu&3pu&:"ine5NEGi,&a 'o%en+i a,i.na&e "uiN61 END1 @

## !3Se da din .re,ea"a un 'odu" an.a=a&u"ui in'ore'&3Sa ,e &ra&e+e a'ea,&a eG'ep&ie3

DECLARE in-a"id:an. EPCE7TION1 BEGIN U7DATE an.a=a&i SET nu%eDNCODREANUN MQERE 'odan.DTTT1 IF ,U"Bno&\$ound TQEN RAISE in-a"id:an.1 END IF1 EPCE7TION MQEN in-a"id:an. TQEN DBMS:OUT7UT37UT:LINE5NNu eGi,&a au&o%o*i" 'u a'e,& 'odN61 END1 @

## E.GESTIONAREA CURSORILOR-IMPLICITI SI E5PLICITI3CU SI FARA PARAMENTRI4.

13Crearea unei &a*e"e Vade+iuniW in 'are -or \$i &re'u&e pri%e"e nu%e0 ade+iuni din &a*e"a 'u a'e"a,i

## END LOO71 CLOSE '11 END1 @ SELECT X FROM ade+iuni1

#3Sa ,e di%inue+e 'u un anu%i& pro'en& nu%aru" de an.a=a&i de "a un anu%i& \$ond de pen,ii, de 'a&e ori apare3 Codu" \$ondu"ui de pen,ii ,i pro'en&u" de di%inuare ,e dau de "a &a,&a&ura3 Sa ,e a\$i,e+e in 'a&e 'o%en+i ,Aau \$a'u& %odi\$i'ari3 a''ep& -:'odp pro%p& Nin&rodu'e&i 'od produ,N a''ep& -:pro'en& pro%p& Nin&rodu'e&i pro'en&u"N de'"are -re+ nu%*er5#61 pro'en& nu%*er1 *e.in pro'en&0DY-:pro'en&1 upda&e \$ondu"depen,ii ,e& nr:an.a=a&iDnr:an.a=a&iA5an:an.a=a&iXpro'en&@1006 C2ere 'od\$ondDNY-:'odpN1 -re+0D,U"BroC'oun&1 d*%,:ou&pu&3pu&:"ine5&o:'2ar5-re+6OON randuri %odi\$i'a&eN61 eG'ep&ion C2en no:da&a:\$ound &2en d*%,:ou&pu&3pu&:"ine5Nnu eGi,&a produ,u"N61 end1 3A\$i,area pri%e"or ade+iuni in ordinea de,'re,'a&oare a in'2eierii "or 3
d&+&&de/

decl&re cursor curs is selec+ comision \$ d&+&&de/ from &de/iuni order b desc0 %&l number((2)0 be,in open curs0 for i in 1??3 loop fe+c' curs in+o comision\$d&+&&de/0 dbms!ou+pu+?pu+!line(8&de/iunile E 8FFcFFcomision)0 end loop0 close curs0 end0 @

F37en&ru \$ie'are \$ond de pen,ii ,a ,e a\$i,e+e 'a&e produ,e din a'e" &ip eGi,&a3

decl&re cursor c1 is selec+ coun+(codfond) num&r from &de/iuni ,roup b codfond0 be,in for rec!c1 in c1 loop dbms!ou+pu+?pu+!line(rec!c1?num&rFF8produse de +ipul 8FF&de/iuni?codfond)0 end loop0 end0 @

## F.FUNCTII,PROCEDURI,INCLUDEREA ACESTORA IN PACHETE.

13Crea&i o pro'edura 'are ,a adau.e o noua per,oana in &a*e"a ANGA?ATI3
SET SER6ERO*TP*T ON Cre&+e or repl&ce procedure &d&u,&!&n, Is

-:'od an.a=a&i3'odan.B&9pe1 -:nu%e an.a=a&i3nu%eB&9pe1 -:prenu%e an.a=a&i3prenu%eB&9pe1 -:'np an.a=a&i3'npB&9pe1 -:\$un'&ie an.a=a&i3\$un'&ieB&9pe1 -:'od\$ond an.a=a&i3'od\$ondB&9pe1 -:adre,a an.a=a&i3adre,aB&9pe1 *e.in in,er& in&o an.a=a&i -a"ue, 58CRISTEA8\$8ANA8\$8(:31(2.)5>:;28\$ 8CONS*LTANT8\$
8(8\$ 8 Bucures+i \$Bd?L&cul Tei8)0

d*%,:ou&pu&3pu&:"ine5Z,Aau inre.i,&ra& ZOO,U"BroC'oun&OOIinre.i,&rariI61 end1 @ ,2oC error, ape"u" pro'edurii0 *e.in adau.a:an.1 end1 @ ,au 'a"" adau.a:an.1

#3Sa ,e 'ree+e o pro'edura 'are are 'a para%e&ru de in&rare 'odu" re'"a%a&iei pen&ru 'are a \$o,& re,pin, par&i'ipan&u" ,i 'a para%e&ru de ie,ire %o&i-u" pen&ru 'are a \$o,& re,pin,3 Da'a nu eGi,&a re'"a%a&ii apare eroarea [nu eGi,&a re'"a%a&iiW iar da'a ,un& doua re'"a%a&ii 'u a'e"a,i %o&iapare eroarea [eGi,&a %ai %u"&e re'"a%a&ii 'u a'e"a,i %o&i-W3

cre&+e or repl&ce procedure &fise&/&(p!cod in recl&m&+ii?codrecl&m&+ieH+ pe\$ p!mo+i% ou+ recl&m&+ii?mo+i%H+ pe) is be,in selec+ mo+i% in+o p!mo+i% from recl&m&+ii B'ere codrecl&m&+ieCp!cod0 eAcep+ion B'en no!d&+&!found +'en r&ise!&pplic&+ion!error(D(2222\$ 8nu eAis+& recl&m&+ie8)0 B'en +oo!m&n !roBs +'en r&ise!&pplic&+ion!error(D(2221\$8eAis+& m&i mul+e recl&m&+ii cu &cel&si mo+i%8)0 end0 @

Ape" ,e& ,er-erou&pu& on -aria*"e .:%o&i- -ar'2ar#5#!61 a''ep& .:'od po%p& Nin&rodu'e&i 'odu" re'"a%a&iei N de'"are -:'od re'"a%a&ii3'odre'"a%a&ieB&9pe0DNY.:'odN1 *e.in a\$i,ea+a5-:'od,0.:%o&i-61 end1 @

3 Sa ,e 'ree+e o pro'edura 'are %are,&e 'o%i,ionu" unei anu%i&e ade+iuni 'u un anu%i& pro'en&3 Se &ra&ea+a eG'ep&ii"e3
CREATE or REPLACE PROCE9*RE m&res+e!comision (cod&de/ IN &de/iuni?nr&de/H+ pe\$ procen+ IN number) IS %!comision &de/iuni?comisionH+ pe0 &de/iune!in%&lid EMCEPTION0 BE4IN *pd&+e &de/iuni Se+ comisionCcomisionG(1Oprocen+@122) P'ere nr&de/Ccod&de/0 if SNLHno+found +'en r&ise &de/iune!in%&lid0 end if0 dbms!ou+pu+?pu+!line(8SD&u modific&+ 8FFSNLHroBcoun+FF8 inre,is+r&ri8)0 eAcep+ion B'en &de/iune!in%&lid +'en dbms!ou+pu+?pu+!line(8Nu eAis+& &de/iune& codul 8FFcod&de/)0 EN90 @ cu

Ape"0 ,e& ,er-erou&pu& on a''ep& -'od pro%p& Nin&rodu'e&i 'od ade+iuneN a''ep& pro' pro%p& Nin&rodu'e&i pro'en&u"N de'"are -:'od ade+iuni3nrade+B&9pe0DY-'od1 -:pro' nu%*er0DYpro'1 -'o%i,ion ade+iuni3'o%i,ionB&9pe1 *e.in %are,&e:'o%i,ion5-:'od,-:pro'61 ,e"e'& 'o%i,ion in&o -'o%i,ion \$ro% ade+iuni C2ere nrade+D-:'od1 d*%,:ou&pu&3pu&:"ine5Nade+iunea 'are are 'odu" NOO-:'odOON e,&e NOO-'o%i,ion61 end1 @

F3Crea&i o \$un'&ie 'are nu%ara ade+iuni"e de "a un anu%i& \$ond de pen,ii da& 'a para%e&ru3 'rea&e or rep"a'e \$un'&ion nr:ade+5p:'od\$ond ade+iuni3'od\$ondB&9pe6 re&urn nu%*er i, -nr nu%*er1 *e.in ,e"e'& 'oun&5nrade+6 in&o -nr \$ro% ade+iuni C2ere 'od\$ondDp:'od\$ond1 re&urn -nr1 end1 @ Ape"0
&ccep+ com promp+ 8in+roduce+i codul fondului de pensii8 decl&re %cod &de/iuni?codfondH&9pe0CIcod0 %&r nu%*er0 be,in %&rECnr!&de/(%cod)0 dbms!ou+pu+?pu+!line(8pen+ru codul 8FF%codFF8 &u fos+ comple+&+e 8FF%&rFF8 &de/iuni8)0 end0 @

!3Sa ,e rea"i+e+e un pa'2e& de a'&ua"i+are a *a+ei de da&e 'are ,a 'uprinda \$un'&ii"e ,i pro'eduri"e rea"i+a&e3
Cre&+e or repl&ce p&cJ&,e &c+u&li/&+e is procedure &de/ (p!cod in &de/iuni?nr&de/H+ pe\$ p!d&+& &de/iuni?d&+&&de/H+ pe\$ p!comision &de/iuni?comisionH+ pe\$ p!fond &de/iuni?codfondH+ pe) 0 procedure &d&u,&!&n,0 procedure &fise&/&(p!cod in recl&m&+ii?codrecl&m&+ieH+ pe\$ p!mo+i% ou+ recl&m&+ii?mo+i%H+ pe)0 PROCE9*RE m&res+e!comision (cod&de/ IN &de/iuni?nr&de/H+ pe\$ procen+ IN number)0 func+ion nr!&de/(p!codfond &de/iuni?codfondH+ pe) re+urn number0 end0 @ s'oB errors0

G.DECLANSATORI.
13Codu" \$ondu"ui pen&ru \$ie'are nou ade+iune adau.a&a e,&e de "a 1 "a 103 Fo"o,ind un &ri..er nu "a,a&i 'a "a in,erare 'odu" \$ondu"ui de 'are apar&ine ,a \$ie di\$eri& de ori'e nu%ar de "a 1 "a 103
Create or replace trigger %erif!fond Before insert or update on &de/iuni For each row Begin If Enew?codfondQ12 then R&ise!&pplic&+ion!error(D2(2(2(\$8&ces+& &de/iune din+re fondurile c&re &u coduri de l& 1 l& 128)0 End if0 End0 @ Show errors0

## nu po&+e s& &ib& dec&+ unul

Te,&are &ri..er0
INSERT INTO &de/iuni 6AL*ES (81318\$TO!9ATE(81.@21@(22:8\$8dd@mm@ 8>28\$81(8)0 8)\$

*. Sa ,e 'ree+e un &ri..er 'u a=u&oru" 'aruia ,a nu %ai pri%i% eroare a&un'i 'and -re% ,a ,&er.e% un par&i'ipan& din &a*e"a 7ar&i'ipan&i3
CREATE OR REPLACE TRIGGER s+er,e!p&r+ BEFORE delete ON p&r+icip&n+i FOR EAC RO! BEGIN delete fro" &de/iuni where nr&de/ C Eold?nr&de/0

EN#0 @

Te,&are &ri..er0
accept nr!&de/ pro"pt 8in+roduce+i nr &de/iunii8 declare %p&r p&r+icip&n+i?nr&de/Ht\$peECInr!&de/0 %egin delete fro" p&r+icip&n+i where nr&de/C%p&r0 end0 @

3De+a'&i-area &ri..erAu"ui de %ai ,u,0 ALTER TABLE par&i'ipan&i ENABLE ALL TRIGGERS1 F3 S&er.erea a'e,&uia0 DRO7 TRIGGER ,&er.e:par&1

## Meniu subsol

### Obține aplicațiile noastre gratuite

Drepturi de autor © 2022 Scribd Inc.

## Meniu subsol

### Obține aplicațiile noastre gratuite

Drepturi de autor © 2022 Scribd Inc.