以下代码运行良好:
create type my_tab_type is object
(tipo char(2), nome varchar2(500), cpf_cnpj varchar2(1),
ie varchar2(1), ie_dev varchar2(1))
/
create type my_tab_type_coll is table of my_tab_type;
/
create or replace function get_some_data (p_val in number)
return my_tab_type_coll pipelined is
begin
FOR i in (select '1a' tipo,'a' nome,'b' cpf_cnpj,'c' ie,'d' ie_dev from dual where 1=0) loop
pipe row(my_tab_type(i.tipo,i.nome,i.cpf_cnpj,i.ie,i.ie_dev));
end loop;
return;
end;
/
SELECT * FROM table(get_Some_Data(1));
此代码不
create type my_tab_type is object
(tipo char(2), nome varchar2(500), cpf_cnpj varchar2(1),
ie varchar2(1), ie_dev varchar2(1))
/
create type my_tab_type_coll is table of my_tab_type;
/
create or replace function get_some_data (p_val in number)
return my_tab_type_coll pipelined is
begin
FOR i in (select '1a' tipo,'a' nome,'b' cpf_cnpj,'c' ie,'d' ie_dev from person where 1=0) loop
pipe row(my_tab_type(i.tipo,i.nome,i.cpf_cnpj,i.ie,i.ie_dev));
end loop;
return;
end;
/
SELECT * FROM table(get_Some_Data(1));
我只是改变了数据的来源(或者不是,因为其中1 = 0)
第一种情况来自双重并且像魅力一样运行
第二种情况来自人,并提供错误invalid state
任何放在查询中的表不是双重的,都会给出无效状态
为什么?