From: Chad Thompson <chad@weblinkservices.com>
To: Anagha Joshi <ajoshi@nulinkinc.com>
To: pgsql-sql@postgresql.org
Subject: Re: Urgent Help : Use of return from function/procedure.
Date: Mon, 23 Jun 2003 10:44:46 -0600
Message-ID: <01d301c339a6$c227f9e0$32021aac@chad> (raw)
References: <FF851C7EEB75954F9BCFB5CA117AB1EC61A446@delta.nulinkinc.com>
Urgent Help : Use of return from function/procedure.
----- Original Message -----
From: Anagha Joshi
To: pgsql-sql@postgresql.org
Sent: Sunday, June 22, 2003 11:42 PM
Subject: [SQL] Urgent Help : Use of return from function/procedure.
Hi,
I'm new to postgres and using version 7.2.4
I've created a trigger and function which does the following:
trigger 'T' fires after insert on a spcific table takes place and it executes function 'F'
Function 'F' returns the new record inserted by 'return new' statement.
Now my question is:
How can I use this 'new' value in my client program? In this prgm., I want to know which all values are inserted into the table.
Help is appreciated.
Thx,
Anagha
Im not sure if this is what you are looking for. But I use postgres this way to know which record I have sent. Its a very simple function and should be self explanitory. I think the GET DIAGNOSTICS is the key for you in this case.
-- Function: public.return_mortgage_id(varchar, varchar)
CREATE FUNCTION public.return_mortgage_id(varchar, varchar) RETURNS int8 AS '
DECLARE
oid1 INTEGER;
retval integer;
BEGIN
insert into mortgage(contact_firstname, contact_lastname, date_submitted)
values($1,$2, now());
GET DIAGNOSTICS oid1 = RESULT_OID;
select id into retval
from mortgage
where oid = oid1;
return retval;
end;' LANGUAGE 'plpgsql' IMMUTABLE;
Hope that helps
Chad
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: chad@weblinkservices.com, ajoshi@nulinkinc.com
Subject: Re: Urgent Help : Use of return from function/procedure.
In-Reply-To: <01d301c339a6$c227f9e0$32021aac@chad>
* 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