From: deepaji@chequemail.com
To: pgsql-sql@postgresql.org
Subject: Returning a row from a function
Date: 7 Feb 2001 05:00:09 +0000
Message-ID: <20010207050009.24668.cpmta@c000.muc.cp.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: deepaji@chequemail.com
Subject: Re: Returning a row from a function
In-Reply-To: <20010207050009.24668.cpmta@c000.muc.cp.net>
References: <20010207050009.24668.cpmta@c000.muc.cp.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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