现在有俩个表question和answer
question中有id和name俩列。
answer中有id,name,quesid.其中quesid为外键。
现在需要一个自定义函数,传入一个question的name进去,返回answer表中对应的name。
现在如果question中有俩个同样name的数据,而且都对应了answer表中的数据,就需要返回多行。
请问应该怎么解决呢?
question中有id和name俩列。
answer中有id,name,quesid.其中quesid为外键。
现在需要一个自定义函数,传入一个question的name进去,返回answer表中对应的name。
现在如果question中有俩个同样name的数据,而且都对应了answer表中的数据,就需要返回多行。
请问应该怎么解决呢?
as
workcursor sys_refcursor;
begin
open workcursor for
select
t.name
from answer t ,question t1
where t.id=t1.quesid and t.quesid in (
select id from question t where t.name=name_param
);
return workcursor;
end p_get_thismonthworkinfo;
P_GET_THISMONTHWORKINFO('DFSD'
------------------------------
<Value Error>
在answer表中并没有存储question的name啊,这个name应该是答案吧。
所以应该传递的question的id再有返回多行,可以返回一个光标的引用,或返回一个数组,都可以解决问题的。
不是的,这个的需要就是传递question的描述进去,然后查出所有符合这个描述的question和对应的answer,所以可能会返回多行