比如说
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;
这一段代码 提示的是 -->警告: 创建的过程带有编译错误。
我该怎么才能看出来时那一行出的错?

解决方案 »

  1.   


    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 过程已成功完成。
      

  2.   

    这个是没有问题的  在那位置 添加这一句 show errors
      

  3.   

    或执行完过程后,SQL>show errors
      

  4.   

    是放在
    set serveroutput on
    show errors
    这样的吧
      

  5.   


    对的!一般show errors会显示具体哪里错误,根据这个信息,你就事半功倍了!
      

  6.   

    不过,如果你的过程或者PL/SQL块很复杂,且代码很多,而且还涉及到业务逻辑等,我一般查找的时候都是采用debug形式,用中间表来存放自己的log,以便跟踪查看。也就是说,创建一张临时表,然后往表中insert数据,最后查看临时表就知道执行到哪一步出的错了。
      

  7.   

    可以写成一个存储过程,然后用test窗口进行调试
      

  8.   

    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));
    close mycursor; --记得 不然会有麻烦的
    end;
    /show err
      

  9.   

    alter table tablename rename to newtablename