create or replace procedure procedure_info(
id in info.nid%type,name out info.name%type)
is
begin
select info.name into name 
from info
where info.nid=id ;
end procedure_info;
declare
names info.name%type;
begin
  procedure_info(1,names);
  select nid,name from info where info.name=names;  --这边出现了错误!
  dbms_output.put_line(names);
end; 错误: 在select语句中缺少了into子句。  
  这是什么问题呢?  
如果换成:
declare
names info.name%type;
begin
  procedure_info(1,names);  dbms_output.put_line(names);
end; 
可以输出names的值!存储select

解决方案 »

  1.   


    在Oracle的PL/SQL中,SELECT里面必须要配合INTO一起使用的需要定义变量来接受SELECT出来的结果.select nid,name from info where info.name=names;  --这边出现了错误!增加INTO语句
      

  2.   

    怎么加into 语句,加在什么位置?
    dbms_output.put_line(names); 可以输出值,那说明names是存在值的。
    怎么就不可以使用:
    select nid,name from info where info.name=names; 
      

  3.   


    你上面用了INTO,为啥后面不一样也用呢?create or replace procedure procedure_info(
    id in info.nid%type,name out info.name%type)
    is
    begin
    select info.name into name 
    from info
    where info.nid=id ;
    end procedure_info;
    declare
    names info.name%type;
    begin
      procedure_info(1,names);
      select nid,name from info where info.name=names;  --这边出现了错误!
      dbms_output.put_line(names);
    end; 错误: 在select语句中缺少了into子句。  
      这是什么问题呢?  
    如果换成:
    declare
    names info.name%type;
    begin
      procedure_info(1,names);  dbms_output.put_line(names);
    end; 
      

  4.   

    select info.name into name 
    from info
    where info.nid=id ;
    end procedure_info;
      

  5.   

    在存储过程中,是不支持
    select直接查询显示数据的,如果要显示结果,你可以通过循环一条条的显示。
      

  6.   

     select nid,name from info where info.name=names;  --这边出现了错误!这条东西放里面是想做什么
      

  7.   


    很感谢你的第一个回复,但是好歹你也要有镇对性一点,比如说我这个写法是否可行? 
    又或者你提的这个 into的建议是否可以执行! 在自己确认可行的时候再来教我的话,我会很感激你的。
    ...