Re: Urgent Help : Use of return from function/procedure. - Mailing list pgsql-sql

From Chad Thompson
Subject Re: Urgent Help : Use of return from function/procedure.
Date
Msg-id 01d301c339a6$c227f9e0$32021aac@chad
Whole thread Raw
In response to Urgent Help : Use of return from function/procedure.  ("Anagha Joshi" <ajoshi@nulinkinc.com>)
List pgsql-sql
 
----- 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 retval
from
mortgage
where
oid = oid1;
return retval;
end;' LANGUAGE 'plpgsql' IMMUTABLE;
 
Hope that helps
Chad

pgsql-sql by date:

Previous
From: "L.V.Boldareva"
Date:
Subject: Re: CREATE table1 FROM table2
Next
From: Randall Lucas
Date:
Subject: Re: TR: Like and =