declare 
num number(4,2);
begin
select price into num
from books
where price>20;
if num>20 then
dbms_output.put_line('大于20');
end if;
end; 
 写了以上代码后,dbms_output.put_line不起作用
end;本来是在第10行,我按回车后又出现11行,不显示结果,
而且 set serveroutput on,set serverout on,这两句我也都试过了,都不行

解决方案 »

  1.   

    加个 /
    SQL> declare
      2  num number(4,2);
      3  begin
      4  select price into num
      5  from books
      6  where price>20;
      7  if num>20 then
      8  dbms_output.put_line('大于20');
      9  end if;
     10  end;
     11  /
      

  2.   

    "if num>20 then"是否为真呢?接分!
      

  3.   

    你就直接运行下面语句,看看有没有结果出来?
    set serveroutput on;
    dbms_output.put_line('大于20'); 
      

  4.   

    "本来是在第10行,我按回车后又出现11行,不显示结果"
    明显你的PL/SQL块还没有结束.
    加一个/再回车就可以了.
    另外,你的
    select price into num 
    from books 
    where price>20;
    没找到合适的行也没有输出的.
    加个exception处理一下吧。
      

  5.   

    在最前面加上 set serveroutput on;  
    在最后面加/