0% found this document useful (0 votes)
44 views6 pages

Exp No: Usage of Cursor Date:: Branch Name, House No (PK), Amount

Download as doc, pdf, or txt
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 6

EXP NO: USAGE OF CURSOR

DATE:
Master Table
Electricity board
Branc na!e" o#se no$P%&" a!o#nt
Transactional table
'&(o#se no$F%&" C#sto!er na!e" Pre)io#s readin*" c#rrent readin*" Unit"
A!o#nt"+la*$S,ecial&

Fla* y or O or s
Create Electricity board and Transaction table" insert - records and #,date #nit
.it te +ollo.in* calc#lation
A!o#nt/$CR0PR &123- and 4rite te P56S75 ,ro*ra! to #,date te !aster table
.it te +ollo.in* condition3
$i&i+ te +la* is y in te c#sto!er table set te !aster table a!o#nt is e8#al to EB
tablea!o#nt 9$TTa!o#nt 1 -:6'::&
$ii&i+ te +la* is O in te c#sto!er table set te !aster table a!o#nt is e8#al to
EBa!o#nt ;TTa!o#nt 1 -:6'::
else
i+ te +la* is s in te c#sto!er table set te !aster table a!o#nt is e8#al to
EBa!o#nt /TTa!o#nt
.rite te c#rsor to #,date te records3
S75< select 1 +ro! e!,table=
EMPNO ENAME >OB MGR (?REDATE SA5 COMM
0000000000 000000 0000000000 0000000000 000000000 0000000000 0000000000
DEPTNO COMPAN@
0000000000 0000000000
ABCD S!it clerE AD:2 'A0DEC0F: F::
2: in+osis
AGDD Allen Sales!an ACDF 2:0FEB0F' 'C:: B::
B: .i,ro
A-2' 4ard Sales!an ACDF 220FEB0F' '2-: -::
B: Tcs
EMPNO ENAME >OB MGR (?REDATE SA5 COMM
0000000000 000000 0000000000 0000000000 000000000 0000000000 0000000000
DEPTNO COMPAN@
0000000000 0000000000
A-CC >ones Mana*er AFBD :'0APR0F' 2DA-
2: Tcs
AC-G Martin Sales!an ACDF 2F0SEP0F' '2-: G::
B: .i,ro
ACDF BlaEe Mana*er AFBD :'0MA@0F' 2F-:
B: in+osis
EMPNO ENAME >OB MGR (?REDATE SA5 COMM
0000000000 000000 0000000000 0000000000 000000000 0000000000 0000000000
DEPTNO COMPAN@
0000000000 0000000000
AAF2 ClarE Mana*er AFBD :D0>UN0F' 2G-:
': .i,ro
AAFF Scott Analyst A-CC :D0DEC0F2 B::
2: Tcs
AFBD %in* ,resident 'A0NOH0F' -:::
': Tcs
EMPNO ENAME >OB MGR (?REDATE SA5 COMM
0000000000 000000 0000000000 0000000000 000000000 0000000000 0000000000
DEPTNO COMPAN@
0000000000 0000000000
AFGG T#rner Sales!an ACDF :F0SEP0F' '-:: :
B: .i,ro
AFAC Ada!s ClerE AAFF '20>AN0FB ''::
2: Tcs
AD:: >a!es ClerE ACDF :B0DEC0F' D-:
B: Tcs
EMPNO ENAME >OB MGR (?REDATE SA5 COMM
0000000000 000000 0000000000 0000000000 000000000 0000000000 0000000000
DEPTNO COMPAN@
0000000000 0000000000
AD:2 Ford Analyst A-CC :G0DEC0F' B:::
2: .i,ro
ADBG Miller ClerE AAF2 2B0>AN0F2 'B::
': Tcs
'G ro.s selected3
S75< desc e!,table=
Na!e N#llI Ty,e
00000000000000000000000000000000000000000 00000000 0000000000000000000000000000
EMPNO NUMBER$G&
ENAME HARC(AR2$C&
>OB HARC(AR2$':&
MGR NUMBER$G&
(?REDATE DATE
SA5 NUMBER$-&
COMM NUMBER$B&
DEPTNO NUMBER$2&
COMPAN@ HARC(AR2$':&
S75< create table e!,Jraise $ e!,no n#!ber$G&" raisedate date" raisea!t
n#!ber$':"2&&=
Table created3
S75< select e!,no"sal +ro! e!, .ere Kob/LSales!anL and de,tno/B:=
EMPNO SA5
0000000000 0000000000
AGDD 'C::
A-2' '2-:
AC-G '2-:
AFGG '-::
S75< declare
2 c#rsor c' is select e!,no"sal +ro! e!,table .ere Kob/LSales!anL and
de,tno/B:=
B eno e!,l'3e!,noMty,e=
G s e!,l'3salMty,e=
- a!o#nt e!,l'3salMty,e=
C be*in
A o,en c'=
F loo,
D +etc c' into eno"s=
': eNit .en c'MNOTFOUND=
'' a!o#nt:/s;s13:-=
'2 #,date e!,table set sal/a!o#nt .ere e!,no/eno=
'B insert into e!,Jraise )al#es$eno"sysdate"a!o#nt&=
'G db!sJo#t,#t3,#tJline$LRecord s#ccess+#lly insertedL&=
'- end loo,=
'C1 end=
P56S75 ,roced#re s#ccess+#lly co!,leted3
S75< set ser)ero#t,#t on=
S75< select e!,no"sal +ro! e!,table .ere Kob/LSales!anL and de,tno/B:=
EMPNO SA5
0000000000 0000000000
AGDD 'CF:
A-2' 'B'B
AC-G 'B'B
AFGG '-A-
S75< select 1 +ro! e!,Jraise=
EMPNO RA?SEDATE RA?SEAMT
0000000000 000000000 0000000000
AGDD 2D0FEB0:F 'CF:
A-2' 2D0FEB0:F 'B'B
AC-G 2D0FEB0:F 'B'B
AFGG 2D0FEB0:F '-A-
S75< create table acctJ!ast$acctno )arcar2$G&" na!e )arcar2$2:&" balance
n#!ber$':"2&&=
Table created3
S75< insert into acctJ!ast )al#es$LA'::L"LS!itL"'::::&=
' ro. created3
S75< insert into acctJ!ast )al#es$LA':'L"L%in*sleyL"-:::&=
' ro. created3
S75< insert into acctJ!ast )al#es$LA':2L"LCarolL"F:::&=
' ro. created3
S75< select 1 +ro! acctJ!ast=
ACCT NAME BA5ANCE
0000 00000000000000000000 0000000000
A':: S!it '::::
A':' %in*sley -:::
A':2 Carol F:::
S75< create table acctJtrans$acctno )arcar2$G&" transdate date"trans+la*
car$'&"a!o#nt n#!ber$F"2&",rocessed car$'&&=
Table created3
S75< insert into acctJtrans )al#es$LA':2L"L'20!ay0'DF:L"LdL"':::"LnL&=
' ro. created3
S75< insert into acctJtrans )al#es$LA'::L"L:G0K#n0'DF:L"LcL"-::"LnL&=
' ro. created3
S75< insert into acctJtrans )al#es$LA':'L"L220!ar0'DF:L"LdL"2-:"LnL&=
' ro. created3
S75< select 1 +ro! acctJtrans=
ACCT TRANSDATE T AMOUNT P
0000 000000000 0 0000000000 0
A':2 '20MA@0F: d '::: n
A':: :G0>UN0F: c -:: n
A':' 220MAR0F: d 2-: n
S75< declare
2 c#rsor c' is select acctno"trans+la*"a!o#nt +ro! acctJtrans .ere ,rocessed/LnL=
B acno acctJtrans3acctnoMty,e=
G +la* acctJtrans3trans+la*Mty,e=
- a!t acctJtrans3a!o#ntMty,e=
C be*in
A o,en c'=
F loo,
D +etc c' into acno"+la*"a!t=
': eNit .en c'MNOTFOUND=
'' i+ +la*/LdL ten
'2 #,date acctJ!ast set balance/balance0a!t .ere acctno/acno=
'B else
'G #,date acctJ!ast set balance/balance;a!t .ere acctno/acno=
'- end i+=
'C #,date acctJtrans set ,rocessed /LyL .ere acctno/acno=
'A end loo,=
'F end=
'D 6
P56S75 ,roced#re s#ccess+#lly co!,leted3
S75< select 1 +ro! acctJtrans=
ACCT TRANSDATE T AMOUNT P
0000 000000000 0 0000000000 0
A':2 '20MA@0F: d '::: y
A':: :G0>UN0F: c -:: y
A':' 220MAR0F: d 2-: y
S75< select 1 +ro! acctJ!ast=
ACCT NAME BA5ANCE
0000 00000000000000000000 0000000000
A':: S!it ':-::
A':' %in*sley GA-:
':2 Carol A:::
RESU5T:
Te #sa*e o+ c#rsor ,ro*ra! is eNec#ted s#ccess+#lly3

You might also like