我写了这样一个程序:
declare
v_sal number(9,2);
v_ename varchar2(20);
begin
select ename,sal into v_ename,v_sal from emp where sal=3000;
dbms_output.put_line('姓名:'||v_ename||',工资:'||v_sal);
when no_date_found then
dbms_output.put_line('sal=3000no date found');
when too_many_rows then
dbms_output.put_line('sal=3000 is to many rows');
end;
/
但是执行的时候报错:
SQL> @1
when no_date_found then
*
ERROR at line 14:
ORA-06550: line 14, column 1:
PLS-00103: Encountered the symbol "WHEN" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
pipe
The symbol "case" was substituted for "WHEN" to continue
ORA-06550: line 18, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
case
我把when no_data_found和when too_many_rows注销掉就可以执行!
请教那位高手能指点一下我的问题错在哪里?
|