Returning a row from a function

From: deepaji(at)chequemail(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: Returning a row from a function
Date: 2001-02-07 05:00:09
Message-ID: 20010207050009.24668.cpmta@c000.muc.cp.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

This is my first experinece in writing to u. Please excuse any obvious errors.

I have only recently started using the postgres database and i would like to know if it is possible to return a record from the fucntion(both sql and plpgsql).

I tried this code.. but the reuslt i got was

create function ret_rec(char(10)) returns setof label as
'
select * from label where label_id = $1'
language 'sql';

hmv=# select ret_rec('L0001');
?column?
-----------
136449928

I also tried this..

create function ret_rec(char(10)) returns label as
'
declare
label_rec record;
begin
select into label_rec * from label where label_id = $1;
return label_rec;
end;'
language 'plpgsql';

hmv=# select ret_rec('L0001');
ret_rec
-----------
136469400
(1 row)

What is the problem and what is this value that is being returned? Is there any other way in which i can handle this?

Please help.

Also, please tell me if there is any way in which i can pass values to a plpgsql function that is being called by a trigger?(ie) this function exceutes when a trigger fires.. can i pass arguments to this function?

Regards and Thanx in advance
Deepa.

Chequemail.com - a free web based e-mail service that also pays!!!
http://www.chequemail.com

Browse pgsql-sql by date

  From Date Subject
Next Message Anatoly K. Lasareff 2001-02-07 07:52:32 Re: PL/PGSQL function with parameters
Previous Message Josh Berkus 2001-02-07 04:15:35 Is this a bug, or is it just me?