比如说
set serveroutput on
declare
tempsal scott.emp.sal%type;
cursor mycursor is
select * from scott.emp
where sal>tempsal;
cursorrecord mycursor%rowtype;
begin
tempsal:=800;
open mycursor;
fetch mycursor into cursorrecord;
dbms_output.put_line(to_char(cursorrecord.deptno));
end;
这一段代码 提示的是 -->警告: 创建的过程带有编译错误。
我该怎么才能看出来时那一行出的错?
set serveroutput on
declare
tempsal scott.emp.sal%type;
cursor mycursor is
select * from scott.emp
where sal>tempsal;
cursorrecord mycursor%rowtype;
begin
tempsal:=800;
open mycursor;
fetch mycursor into cursorrecord;
dbms_output.put_line(to_char(cursorrecord.deptno));
end;
这一段代码 提示的是 -->警告: 创建的过程带有编译错误。
我该怎么才能看出来时那一行出的错?
show errors --查看错误
--不过我在sqlplus执行你的过程没有错误的
SQL> declare
2 tempsal scott.emp.sal%type;
3 cursor mycursor is
4 select * from scott.emp
5 where sal>tempsal;
6 cursorrecord mycursor%rowtype;
7 begin
8 tempsal:=800;
9 open mycursor;
10 fetch mycursor into cursorrecord;
11 dbms_output.put_line(to_char(cursorrecord.deptno));
12 end;
13 /
30PL/SQL 过程已成功完成。
set serveroutput on
show errors
这样的吧
对的!一般show errors会显示具体哪里错误,根据这个信息,你就事半功倍了!
/declare
tempsal scott.emp.sal%type;
cursor mycursor is
select * from scott.emp
where sal>tempsal;
cursorrecord mycursor%rowtype;
begin
tempsal:=800;
open mycursor;
fetch mycursor into cursorrecord;
dbms_output.put_line(to_char(cursorrecord.deptno));
close mycursor; --记得 不然会有麻烦的
end;
/show err