pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Urgent Help : Use of return from function/procedure.
3+ messages / 3 participants
[nested] [flat]

* Urgent Help : Use of return from function/procedure.
@ 2003-06-23 05:42 Anagha Joshi <ajoshi@nulinkinc.com>
  2003-06-23 10:55 ` Re: Urgent Help : Use of return from function/procedure. Richard Huxton <dev@archonet.com>
  2003-06-23 16:44 ` Re: Urgent Help : Use of return from function/procedure. Chad Thompson <chad@weblinkservices.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Anagha Joshi @ 2003-06-23 05:42 UTC (permalink / raw)
  To: pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Urgent Help : Use of return from function/procedure.
  2003-06-23 05:42 Urgent Help : Use of return from function/procedure. Anagha Joshi <ajoshi@nulinkinc.com>
@ 2003-06-23 10:55 ` Richard Huxton <dev@archonet.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Richard Huxton @ 2003-06-23 10:55 UTC (permalink / raw)
  To: Anagha Joshi <ajoshi@nulinkinc.com>; pgsql-sql

On Monday 23 Jun 2003 6:42 am, Anagha Joshi wrote:
> 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.

Short answer - you don't. I'm not sure why you want to do this - if you just 
inserted the new values, surely you know what they are?

There was something very similar to this last week, I'd have a look in the 
mailing-list archives at http://archives.postgresql.org - it was either this 
list or "general".

-- 
  Richard Huxton



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Urgent Help : Use of return from function/procedure.
  2003-06-23 05:42 Urgent Help : Use of return from function/procedure. Anagha Joshi <ajoshi@nulinkinc.com>
@ 2003-06-23 16:44 ` Chad Thompson <chad@weblinkservices.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Chad Thompson @ 2003-06-23 16:44 UTC (permalink / raw)
  To: Anagha Joshi <ajoshi@nulinkinc.com>; pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-06-23 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23 05:42 Urgent Help : Use of return from function/procedure. Anagha Joshi <ajoshi@nulinkinc.com>
2003-06-23 10:55 ` Richard Huxton <dev@archonet.com>
2003-06-23 16:44 ` Chad Thompson <chad@weblinkservices.com>

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