INPUT
declare
mno A1.ano%type;
mbal A1.balance%type;
bal number(5);
oper varchar2(1);
exnull exception;
min exception;
pragma exception_init(exnull,00100);
begin
mno:=&mno;
oper:='&oper';
select balance into mbal from A1
where ano=mno;
bal:=&bal;
if oper='c' then
update A1 set
balance=balance+bal where ano=mno;
elsif oper='d' then
mbal:=mbal-bal;
if mbal<500 then
raise min;
else
update A1 set balance=balance-bal where ano=mno;
end if;
end if;
exception
when exnull then
dbms_output.put_line('there
is no account of no'||mno);
when min then
dbms_output.put_line('balance
is less than 500 so cant debite sucessful');
end;
/
OUTPUT
1)
Enter value for mno: 10
old
10: mno:=&mno;
new
10: mno:=10;
Enter value for oper: c
old
11: oper:='&oper';
new
11: oper:='c';
Enter value for bal: 1000
old
13: bal:=&bal;
new
13: bal:=1000;
there is no account of no10
PL/SQL procedure successfully
completed.
2)
Enter value for mno: 105
old
10: mno:=&mno;
new
10: mno:=105;
Enter value for oper: d
old
11: oper:='&oper';
new
11: oper:='d';
Enter value for bal: 6000
old
13: bal:=&bal;
new
13: bal:=6000;
balance is less than 500 so cant debite
sucessful
PL/SQL procedure successfully
completed.
0 Comments