为什么在pl/sql developer 的命令窗口下直接运行这句select name,phone from friend where name='张哲';
就可以放在下面的过程中就提示出错呢?create or replace procedure Test is
 v_code varchar2(100);
begin
v_code:='&编号';
select name,phone from friend where name='张哲';
end Test;我想着过程中实现select name,phone from friend where name='张哲';查询

解决方案 »

  1.   

    create or replace procedure Test is 
     v_code varchar2(100); 
    v_name varchar2(100);
    v_phone varchar2(20)
    begin 
    v_code:='&编号'; 
    select name,phone 
        into v_name,v_phone
    from friend where name='张哲'; 
    end Test;  如果单条纪录可以这样写,如果是多条纪录就要用游标了
      

  2.   

    存储过程中要用 select into
      

  3.   


    这个我在PL/SQL developer 6.0 的sql窗口下编译出错,我的表没问题
      

  4.   

    create or replace procedure Test is  
     v_code varchar2(100);  
    v_name varchar2(100); 
    v_phone varchar2(20); 
    begin  
    v_code:='&编号';  
    select name,phone  
        into v_name,v_phone 
    from friend where name='张哲';  
    end Test; v_phone varchar2(20) 后面少个分号而已。