home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp2.sql,v 1002100.2 90/01/11 16:54:19 nsalah Exp $ examp2.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
- /*
- ** This block debits account #3 by $500 only if there are enough funds
- ** to cover the withdrawal.
- **
- ** Copyright (c) 1989 by Oracle Corporation
- */
-
- DECLARE
- acct_balance NUMBER(11,2);
- ACCT CONSTANT NUMBER(2) := 3;
- DEBIT_AMT CONSTANT NUMBER(5,2) := 500.00;
- BEGIN
- SELECT bal INTO acct_balance FROM accounts
- WHERE account_id = ACCT;
-
- IF acct_balance >= DEBIT_AMT THEN
- UPDATE accounts SET bal = bal - DEBIT_AMT
- WHERE account_id = ACCT;
- ELSE
- INSERT INTO temp VALUES
- (ACCT, acct_balance, 'Insufficient funds.');
- -- insert account, current balance, and message
- END IF;
- END;
- /
-