日期:2014-05-17  浏览次数:20679 次

存储过程问题,求大神!
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

------解决方案--------------------
引用:
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的值!


在Oracle的PL/SQL中,SELECT里面必须要配合INTO一起使用的

需要定义变量来接受SELECT出来的结果.

select nid,name from info where info.name=names;  --这边出现了错误!

增加INTO语句

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