passing a record as a function argument in pl/pgsql
passing a record as a function argument in pl/pgsql
От:
"Alon Noy" <anoy@arti-shock.com>
Дата:
Is it possible?
From what I tried it is possible to create such a function but it is not possible to call it ?!
Can anyone provide an example?
Tnx.
Re: passing a record as a function argument in pl/pgsql
От:
Joe Conway <mail@joeconway.com>
Дата:
Alon Noy wrote: > From what I tried it is possible to create such a function but it is not > possible to call it ?! > Can anyone provide an example? create table foo (f1 int, f2 text); insert into foo values(1,'a'); insert into foo values(2,'b'); insert into foo values(3,'c'); create or replace function get_foo(int) returns foo as 'select * from foo where f1 = $1' language 'sql'; create or replace function use_foo(foo) returns text as ' declare v_foo alias for $1; begin return v_foo.f2; end; ' language 'plpgsql'; regression=# select use_foo(get_foo(2)); use_foo --------- b (1 row) HTH, Joe