declare
   v_emp emp%rowtype;
begin
   select * into v_emp from emp where empno=7369;
   dbms_output.put_line(v_emp.ename);
end;在pl/sql里面执行不会输出结果。为什么呢?

解决方案 »

  1.   


    set serveroutput on;
    declare 
      v_emp emp%rowtype; 
    begin 
      select * into v_emp from emp where empno=7369; 
      dbms_output.put_line(v_emp.ename); 
    end;
      

  2.   

    得打开输出,执行前加
    set serveroutput on;
      

  3.   

    执行过程前输入命令
    set serveroutput on;
      

  4.   

    set serveroutput on;
    declare 
     v_sal emp.sal%type;
    begin
     select sal into v_sal from emp
      where empno = 7369;
    if(v_sal<1200) then
     dbms_output.put_line('low');
    elsif(v_sal<2000) then
     dbms_output.put_line('middle');
     else
     dbms_output.put_line('high');
    end if;
    end;
    /  加上后在客户端运行了下,说ORA-00922:缺少或无效选项
      

  5.   

    C:\Documents and Settings\Admin>sqlplus scott/tigerSQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 12 23:38:14 2009Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining optionsSQL> set serveroutput on;
    SQL> declare
      2  v_sal emp.sal%type;
      3  begin
      4  select sal into v_sal from emp
      5    where empno = 7369;
      6  if(v_sal <1200) then
      7  dbms_output.put_line('low');
      8  elsif(v_sal <2000) then
      9  dbms_output.put_line('middle');
     10  else
     11  dbms_output.put_line('high');
     12  end if;
     13  end;
     14  /
    lowPL/SQL procedure successfully completed.SQL>
      

  6.   


    plsql可能需要某个菜单里面的某个选项设置一下,不需要这个命令吧。没用过的工具问题就搞不懂了。
      

  7.   

    公司里一般不用sql/plus这样黑乎乎oracle自带的东西,一般是用pl/sql。
      

  8.   

    sql/plus也有不是黑糊糊的界面啊,嘿嘿。
      

  9.   

    sql*plus worksheet....
    呵呵。不过开发还是用pl/sql或toad好调试点。
      

  10.   

    可以输出结果呀,你在执行按F8以后,你在output选项就可以看到输出结果了。嘻嘻
      

  11.   

    set serveroutput on; 
    declare 
    v_sal scott.emp.sal%type; 
    begin 
    select sal into v_sal from scott.emp 
      where empno = 7369; 
    if(v_sal <1200) then 
    dbms_output.put_line('low'); 
    elsif(v_sal <2000) then 
    dbms_output.put_line('middle'); 
    else 
    dbms_output.put_line('high'); 
    end if; 
    end;
      

  12.   

    在pl/sql developer 里面看不到执行结果啊!output选项在哪?我操作的步骤是New----SQLWindows---然后在里编辑:
    set serveroutput on; 
    declare 
    v_sal scott.emp.sal%type; 
    begin 
    select sal into v_sal from scott.emp 
      where empno = 7369; 
    if(v_sal <1200) then 
    dbms_output.put_line('low'); 
    elsif(v_sal <2000) then 
    dbms_output.put_line('middle'); 
    else 
    dbms_output.put_line('high'); 
    end if; 
    end;
    然后按F8执行,可是看不到运行结果啊?