Re: Urgent Help : Use of return from function/procedure.
От | Chad Thompson |
---|---|
Тема | Re: Urgent Help : Use of return from function/procedure. |
Дата | |
Msg-id | 01d301c339a6$c227f9e0$32021aac@chad обсуждение исходный текст |
Ответ на | Urgent Help : Use of return from function/procedure. ("Anagha Joshi" <ajoshi@nulinkinc.com>) |
Список | pgsql-sql |
----- Original Message -----From: Anagha JoshiSent: Sunday, June 22, 2003 11:42 PMSubject: [SQL] Urgent Help : Use of return from function/procedure.Hi,
I'm new to postgres and using version 7.2.4I'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
В списке pgsql-sql по дате отправления: