Oracle ORA-06550:第9行第17列:PLS-00201:
删除Oracle ORA-06550:第9行第17列:PLS-00201:,oracle,Oracle,删除oper:=&oper 在您的情况下,尝试以下方法: ORA-06550: line 9, column 17: PLS-00201: identifier 'D' must be declared ORA-06550: line 9, column 5: PL/SQL: Statement ignored ORA-06550: line 10, column 18: PLS-00201: identifier 'C' must be declared 同样地 IF &oper :
oper:=&oper代码>
在您的情况下,尝试以下方法:
ORA-06550: line 9, column 17:
PLS-00201: identifier 'D' must be declared
ORA-06550: line 9, column 5:
PL/SQL: Statement ignored
ORA-06550: line 10, column 18:
PLS-00201: identifier 'C' must be declared
同样地
IF &oper := 'D' THEN
因此,您的查询如下所示:
ELSIF &oper := 'C' THEN
声明
账户余额(11,2);
账户编号VARCHAR2(10);
交易金额编号(11,2);
操作字符(1);
超过余额的例外情况;
PRAGMA EXCEPTION_INIT(大于余额,-00054);
开始
会计科目编号:=&会计科目编号;
交易金额:=&交易金额;
选择路缘
进入账户余额
来自acct\U mstr
其中账户编号=账户编号;
如果&oper:=“D”,则
如果交易金额<账户余额,则
更新帐户
设置路缘=路缘-运输金额
其中账户编号=账户编号;
其他的
筹集比余额更多的资金;
如果结束;
ELSIF&oper:='C'然后
更新帐户
设置路缘=路缘+运输金额
其中账户编号=账户编号;
如果结束;
例外情况
当超过平衡时
dbms|U output.Put|行('试图从帐户numebr'| acct|U num中提取超过当前余额'| acct|U balance |');
结束;
帐户编号和操作是varchar/char字段,它应该在单引号中。。。如下
DECLARE
acct_balance NUMBER(11, 2);
acct_num VARCHAR2(10);
trans_amt NUMBER(11, 2);
oper CHAR(1);
more_than_balance EXCEPTION;
PRAGMA EXCEPTION_INIT (more_than_balance, -00054);
BEGIN
acct_num := &acct_num;
trans_amt := &trans_amt;
SELECT curbal
INTO acct_balance
FROM acct_mstr
WHERE acct_no = acct_num;
IF &oper := 'D' THEN
IF trans_amt < acct_balance THEN
UPDATE acct_mstr
SET curbal = curbal - trans_amt
WHERE acct_no = acct_num;
ELSE
RAISE more_than_balance;
END IF;
ELSIF &oper := 'C' THEN
UPDATE acct_mstr
SET curbal = curbal + trans_amt
WHERE acct_no = acct_num;
END IF;
EXCEPTION
WHEN more_than_balance THEN
dbms_output.Put_line('attempted to withdraw more than the current balance ' || acct_balance ||'from the account numebr' ||acct_num);
END;
@不客气。如果这对你有帮助,一定要接受这个答案!Thomas Kyte希望我们使用VARCHAR2
类型,CHAR
类型与VARCHAR2
相比没有优势。因此,不要使用CHAR
类型。
DECLARE
acct_balance NUMBER(11, 2);
acct_num VARCHAR2(10);
trans_amt NUMBER(11, 2);
oper CHAR(1);
more_than_balance EXCEPTION;
PRAGMA EXCEPTION_INIT (more_than_balance, -00054);
BEGIN
acct_num := &acct_num;
trans_amt := &trans_amt;
SELECT curbal
INTO acct_balance
FROM acct_mstr
WHERE acct_no = acct_num;
IF &oper := 'D' THEN
IF trans_amt < acct_balance THEN
UPDATE acct_mstr
SET curbal = curbal - trans_amt
WHERE acct_no = acct_num;
ELSE
RAISE more_than_balance;
END IF;
ELSIF &oper := 'C' THEN
UPDATE acct_mstr
SET curbal = curbal + trans_amt
WHERE acct_no = acct_num;
END IF;
EXCEPTION
WHEN more_than_balance THEN
dbms_output.Put_line('attempted to withdraw more than the current balance ' || acct_balance ||'from the account numebr' ||acct_num);
END;
acct_num := '&acct_num';
oper := '&oper';