各位前辈,我已经创建好管道函数,如下简单显示:create or replace function f_showtxsx()
return table_showtxsx pipelined is
pragma autonomous_transaction; v_obj_table row_showtxsx;
zyryxs varchar2(200);
crsglcs varchar2(200);begin
/*这是表1*/
select (这里是表1的字段名和字符串拼成的,如:t.id||'创建'这种形式) into zyryxs from emp t /*这里还有张表2*/
select (这里是表2的字段名和字符串拼成的,如:t.id||'创建'这种形式) into crsglcs from emp t,leyo b where
t.id=b.emp_id v_obj_table:=row_showtxsx(zyryxs,crsglcs);
pipe row(v_obj_table);
commit;
return;
end f_showtxsx;输出结果是:没有记录的
但是我这边sql语句单独查过,虽然表1没有数据但表2是有数据的,为什么sql语句查这个函数会没有显示出来.
哪位前辈指导下,谢谢.
return table_showtxsx pipelined is
pragma autonomous_transaction; v_obj_table row_showtxsx;
zyryxs varchar2(200);
crsglcs varchar2(200);begin
/*这是表1*/
select (这里是表1的字段名和字符串拼成的,如:t.id||'创建'这种形式) into zyryxs from emp t /*这里还有张表2*/
select (这里是表2的字段名和字符串拼成的,如:t.id||'创建'这种形式) into crsglcs from emp t,leyo b where
t.id=b.emp_id v_obj_table:=row_showtxsx(zyryxs,crsglcs);
pipe row(v_obj_table);
commit;
return;
end f_showtxsx;输出结果是:没有记录的
但是我这边sql语句单独查过,虽然表1没有数据但表2是有数据的,为什么sql语句查这个函数会没有显示出来.
哪位前辈指导下,谢谢.
---------------------------------------------------
这句没有返回,存储过程/函数碰到SQLCODE返回不为0时,就会自动终止后面的语句执行。我的习惯是,执行select ... into ... 之前,先执行一个select count(*) into ....,当判断有记录时再去读取。select count(*)基本上总是返回成功。
从上面看来
表1就是查emp --你说emp没有数据
表2是emp t,leyo b做连接 关联条件 t.id=b.emp_id
emp是空的,表2哪来的数据???