Friday, 9 January 2015

Pl/sql program to debit the amount and check the minimum bal 500 while debiting the account

Sql>Create table account(name varchar2(20),anumber varchar2(15),bal number(8,2));

Output: Table created

Sql>insert into account values('abc','101',5000);

Output: row inserted

Sql>insert into account values('abcd','102',500);

Output: row inserted

Sql>insert into account values('ganesh','103',3000);

Output: row inserted.

Sql>insert into account values('raju','104',1000);

Output: row inserted

Sql>insert into account values('gani','105',9000);

Output: row inserted.

Program:

 
declare
acct _bal number(8,2);
acct_no varchar2(15);
debit_amt number(5);
min_bal Number(5);=500;
begin
acct_no:=&acct_no;
debit_amt:=&debit_amt;
select bal into acct_bal from account
      where anumber=acct_no;
acct_bal:=acct_bal-debit_amt;
if  acct_bal>=min_bal then
update account set bal=bal-debit_
     amt where anumber:=acct_no;
else
dbms_output.put_line('insufficient
     bal in the output ');
end if;
end;
/

No comments:

Post a Comment