----- Original Message -----
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 retvalfrom
mortgagewhere
oid = oid1;return retval;
end;' LANGUAGE 'plpgsql' IMMUTABLE;
Hope that helps
Chad