Hi ,
We do have unnest operation in PostgreSQL for fetching the records from any arrary.
edb=# select unnest(fn_Test());
NOTICE: {SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER}
unnest
----------
(SMITH)
(ALLEN)
(WARD)
--Dinesh
We do have unnest operation in PostgreSQL for fetching the records from any arrary.
Step 1
======
Create a sample UDT as below.
create type t_type as (a varchar);
Step 2
======
Create a sample procedure as below.
create or replace function fn_test()
return t_type[]
is
v t_type[];
begin
raise notice '%',array(select ename from emp);
select array(select row(ename) from emp)::varchar[] into v;
return v;
end;
return t_type[]
is
v t_type[];
begin
raise notice '%',array(select ename from emp);
select array(select row(ename) from emp)::varchar[] into v;
return v;
end;
Step 3
======edb=# select unnest(fn_Test());
NOTICE: {SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER}
unnest
----------
(SMITH)
(ALLEN)
(WARD)
--Dinesh
Comments
Post a Comment