Re: passing a record as a function argument in pl/pgsql

From: Joe Conway <mail(at)joeconway(dot)com>
To: Alon Noy <anoy(at)arti-shock(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: passing a record as a function argument in pl/pgsql
Date: 2003-07-02 02:25:37
Message-ID: 3F0242A1.7090306@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Don Soledad 2003-07-02 02:42:58 columnar format
Previous Message Joe Conway 2003-07-02 01:42:18 Re: LEAST and GREATEST functions?