Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DF8C8475AFF for ; Tue, 31 Dec 2002 10:49:53 -0500 (EST) Received: from hotmail.com (f60.sea2.hotmail.com [207.68.165.60]) by postgresql.org (Postfix) with ESMTP id 3ED07475843 for ; Tue, 31 Dec 2002 10:49:53 -0500 (EST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 31 Dec 2002 07:49:57 -0800 Received: from 144.171.145.18 by sea2fd.sea2.hotmail.msn.com with HTTP; Tue, 31 Dec 2002 15:49:57 GMT X-Originating-IP: [144.171.145.18] From: "J D" To: pgsql-sql@postgresql.org Subject: plpgsql select into question Date: Tue, 31 Dec 2002 10:49:57 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 31 Dec 2002 15:49:57.0842 (UTC) FILETIME=[451DFB20:01C2B0E4] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/276 X-Sequence-Number: 10864 sorry if I've sent this to the wrong list... what is the proper way to do the following from within a plpgsql proc: (where table2 is a variable...) select into user_id max(id) from table2 This is part of a procedure that inserts a new record into table1 (table1 has an auto-incrementing id field). Then a trigger inserts a new record into table2 using max() to get the new id from table1 (the trigger fires after insert on table1), then the procedure updates table2. In order to update table2, I need to get the max(id) so I can do: update table2 set .... where id = user_id Thanks very much. And I'm grateful for ideas about a better strategy. cheers, jd _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 3 months FREE*. http://join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU= http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_virusprotection_3mf