From: | "Chad Thompson" <chad(at)weblinkservices(dot)com> |
---|---|
To: | "Anagha Joshi" <ajoshi(at)nulinkinc(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Urgent Help : Use of return from function/procedure. |
Date: | 2003-06-23 16:44:46 |
Message-ID: | 01d301c339a6$c227f9e0$32021aac@chad |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Urgent Help : Use of return from function/procedure.
----- Original Message -----
From: Anagha Joshi
To: pgsql-sql(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Randall Lucas | 2003-06-23 16:53:39 | Re: TR: Like and = |
Previous Message | Nicolas JOUANIN | 2003-06-23 16:29:51 | TR: Like and = |