pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
passing a record as a function argument in pl/pgsql
2+ messages / 2 participants
[nested] [flat]

* passing a record as a function argument in pl/pgsql
@ 2003-07-01 09:01 Alon Noy <anoy@arti-shock.com>
  2003-07-02 02:25 ` Re: passing a record as a function argument in pl/pgsql Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Alon Noy @ 2003-07-01 09:01 UTC (permalink / raw)
  To: pgsql-sql

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.
 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: passing a record as a function argument in pl/pgsql
  2003-07-01 09:01 passing a record as a function argument in pl/pgsql Alon Noy <anoy@arti-shock.com>
@ 2003-07-02 02:25 ` Joe Conway <mail@joeconway.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Joe Conway @ 2003-07-02 02:25 UTC (permalink / raw)
  To: Alon Noy <anoy@arti-shock.com>; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-07-02 02:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-01 09:01 passing a record as a function argument in pl/pgsql Alon Noy <anoy@arti-shock.com>
2003-07-02 02:25 ` Joe Conway <mail@joeconway.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox