Thread: inserting arrays from plpgsql.

inserting arrays from plpgsql.

From
Bhuvan A
Date:
Dear all,

i am trying to insert an array from a plpgsql function. But it didnt
work and i didnt know where i am wrong. hope to get some lights.

my need is something like this..

create table po
( comp_code text, po_no text, po_details text[]
);    
create table xx
( comp_code text, po_no text, po_line1 text, po_line2 text
);

and my function is..

create function ftest()
returns opaque as 'declare
 array_params po.po_details%type;

begin array_params := {new.po_line1, new.po_line2}; insert into po values (comp_code, po_no, params)
values(new.comp_code,new.po_no, array_params);
 

return new;
end;'
language 'plpgsql';

create trigger ttest after insert on xx for each row execute
procedure ftest();

----

my need is not exactly the same, but very similar.
Will be very happy, if I get some lights!         
Regards,
Bhuvaneswaran.