为什么我在 table (acct_trans) 中插入事务详细信息时出现 Oracle 存储过程错误?

Why i am getting oracle stored procedure error while inserting transaction details in a table (acct_trans)?

我想使用存储过程执行银行交易,在存储过程后的第二个 table 中进行取款或存款并存储交易详细信息。

---creating table to store account details----
create table Acct_master(
    accno   number,
    acname  varchar2(20),
    bal     number)
    
select * from Acct_master;
    
Insert into acct_master values(1,'kumar',10000);

--- creating second table to insert data after stored procedure runs---
create table Acct_Trans(
    TRID number,
    Ttype char(1),
    Tamt number,
    Accno number);

---created sequenece---
create sequence tseq
    minvalue 1
    increment by 1
    maxvalue 9999999;

 ---stored procedure to perform transaction---   

 declare
    v_accno aact_master.accno%type;
    v_ttype ACCT_TRANS.TtYPE%type;
    v_amt ACCT_TRANS.Tamt%type;
    v_bal acct_master.bal%type;
    v_trid acct_trans.trid%type;
    amount number(7,2);
  begin
    v_accno:=&accno;
    v_ttype:=&ttype;
    v_amt:=&amount;
    select bal into v_bal from acct_master where accno=v_accno;
    if v_ttype='w'and v_amt>v_bal then
    dbms_output.put_line('insufficient funds');
    elsif v_ttype='w' and v_amt<=v_bal then
    update acct_master set bal=bal-v_amt where accno=v_accno;
    v_trid:=tseq.nextval;
    insert into acct_trans(trid,ttype,tamt,accno)
    values(v_trid,v_ttype,v_amt,v_accno)
    elsif v_ttype='d' then
    update acct_master set bal=bal+v_amt where accno=v_accno;
    v_trid:=tseq.nextval;
    insert into  acct_trans(trid,ttype,tamt,accno)
    values(v_trid,'d',v_amt,v_accno)
    else
    dbms_output.put_line('invalid transaction');
    end if;
    commit;
  end;

缺少分号作为命令终止符。一旦修复,程序 执行 (我不知道是否正确):

SQL> DECLARE
  2     v_accno  Acct_Trans.accno%TYPE;
  3     v_ttype  Acct_Trans.TtYPE%TYPE;
  4     v_amt    Acct_Trans.Tamt%TYPE;
  5     v_bal    Acct_master.bal%TYPE;
  6     v_trid   Acct_Trans.trid%TYPE;
  7     amount   NUMBER (7, 2);
  8  BEGIN
  9     v_accno := &accno;
 10     v_ttype := &ttype;
 11     v_amt := &amount;
 12
 13     SELECT bal
 14       INTO v_bal
 15       FROM acct_master
 16      WHERE accno = v_accno;
 17
 18     IF     v_ttype = 'w'
 19        AND v_amt > v_bal
 20     THEN
 21        DBMS_OUTPUT.put_line ('insufficient funds');
 22     ELSIF     v_ttype = 'w'
 23           AND v_amt <= v_bal
 24     THEN
 25        UPDATE acct_master
 26           SET bal = bal - v_amt
 27         WHERE accno = v_accno;
 28
 29        v_trid := tseq.NEXTVAL;
 30
 31        INSERT INTO acct_trans (trid,
 32                                ttype,
 33                                tamt,
 34                                accno)
 35             VALUES (v_trid,
 36                     v_ttype,
 37                     v_amt,
 38                     v_accno);
 39     ELSIF v_ttype = 'd'
 40     THEN
 41        UPDATE acct_master
 42           SET bal = bal + v_amt
 43         WHERE accno = v_accno;
 44
 45        v_trid := tseq.NEXTVAL;
 46
 47        INSERT INTO acct_trans (trid,
 48                                ttype,
 49                                tamt,
 50                                accno)
 51             VALUES (v_trid,
 52                     'd',
 53                     v_amt,
 54                     v_accno);
 55     ELSE
 56        DBMS_OUTPUT.put_line ('invalid transaction');
 57     END IF;
 58
 59     COMMIT;
 60  END;
 61  /

Enter value for accno: 1
Enter value for ttype: 1
Enter value for amount: 1

PL/SQL procedure successfully completed.

SQL>