Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5974A476026 for ; Mon, 20 May 2002 10:12:55 -0400 (EDT) Received: from localhost (pD9E4FBD8.dip.t-dialin.net [217.228.251.216]) by postgresql.org (Postfix) with ESMTP id C24B0475C78 for ; Mon, 20 May 2002 10:08:32 -0400 (EDT) Received: from eckhard by localhost with local (Exim 3.35 #1 (Debian)) id 179nq0-0001iB-00 for ; Mon, 20 May 2002 16:08:36 +0200 Date: Mon, 20 May 2002 16:08:36 +0200 From: Eckhard Hoeffner To: SQL PostgreSQL Subject: Using LASTOID in one query Message-ID: <20020520140835.GA6211@fifoost.org> Mail-Followup-To: SQL PostgreSQL Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.3.28i X-Archive-Number: 200205/201 X-Sequence-Number: 7836 Is there a possibility to use the last OID from PHP within one query? I have two tables like the following:=20 table_a:=20 number1 serial PRIMARY KEY a_text text table_b:=20 number1 integer REFERENCES table_a, b_text text I am retrieving data like a_text =3D something b_text =3D something else With psql I would do the following: BEGIN; INSERT INTO table_a (a_text) VALUES ('something'); INSERT 224490 1 SELECT number1 FROM table_a WHERE oid =3D 224490; number1=20 ------- 9 (1 row) INSERT INTO table_b (number1, b_text) VALUES (9, 'something else');=20 INSERT 224491 1; COMMIT; If I am using php, the only solution I know is:=20 1. make the first INSERT, execute it 2. get the last oid and make the next query, execute it 3. make the second INSERT This are 3 queries and I can not do it within a transaction.=20 --=20 --//--\\-- Eckhard Hoeffner e-hoeffner@fifoost.org Tal 44=20 D-80331 M=FCnchen