09-07-2011, 10:50 AM
Write a query that will accept an account no. from the user and debit an amount of 2000 from the account. If account has a min. balance of 500 after the balance is debited. The process is to be fired on the account table
PROGRAM CODE:
DECLARE
acct_balance number(11,2);
acct_no VARCHAR2(6);
debit_amt NUMBER(5) := 2000;
min_bal CONSTANT number(5,2):=500.00;
BEGIN
acct_no := '&acct_no';
SELECT bal into acct_balance
FROM accounts
where account_id=acct_no;
acct_balance:=acct_balance-debit_amt;
IF acct_balance >= min_bal then
update accounts set bal= bal- debit_amt
where account_id=acct_no;
END IF;
END;
OUTPUT:
[attachment=14368]