2011-05-15 30 views
-1

我该如何创建带有参数的ref curser并从plsql函数返回这个光标? 我试着写这样的代码..用参数创建ref curser?

create or replace function get_ref_cur(id in number) return sys_refcursor is 
ref_curs sys_refcursor; 
begin 
    open ref_curs(std_id number) for select * from student where id = std_id; 
return ref_curs; 
end; 

但是这个代码不工作。

+0

每个问题一个'?'就足够了。 “没有工作”不是一个好问题描述,请说明它做了什么/不做什么(无法​​编译?,返回错误数据?,...) – Mat 2011-05-15 08:57:50

+0

什么是“ID”和“STD_ID”?如果ID是一个表列,则不需要它作为函数参数的名称。如果STD_ID是表列,那么“(std_id号码)”试图做什么? – 2011-05-15 09:55:27

+0

id是一个表列,而std_id是游标参数问题,在我写入游标的参数时打开ref_curs(std_id number)编译器给出语法错误。 – sahar 2011-05-15 10:56:47

回答

1

您不应该需要将参数应用于普通的sys_refcursor。

create or replace function get_ref_cur(id in number) return sys_refcursor is 
ref_curs sys_refcursor; 
begin 
    open ref_curs for select * from student where std_id = id; 
return ref_curs; 
end;