X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1A2A9563E6 for ; Mon, 21 Mar 2005 12:43:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73635-05 for ; Mon, 21 Mar 2005 12:43:11 +0000 (GMT) Received: from mosaic02.mosaic.de (mosaic02.mosaic.de [195.247.16.18]) by svr1.postgresql.org (Postfix) with ESMTP id 57E80563D9 for ; Mon, 21 Mar 2005 12:43:09 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mosaic02.mosaic.de (Postfix) with ESMTP id 2833B778A3; Mon, 21 Mar 2005 13:43:40 +0100 (CET) Received: from mosaic02.mosaic.de ([127.0.0.1]) by localhost (mosaic02.mosaic-ag.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13597-10; Mon, 21 Mar 2005 13:43:39 +0100 (CET) Received: by mosaic02.mosaic.de (Postfix, from userid 10) id 5C8C777883; Mon, 21 Mar 2005 13:43:39 +0100 (CET) Received: from [172.17.1.87] (aupc287.mosaic-ag.com [172.17.1.87]) by mailsrv.mosaic-ag.com (Postfix) with ESMTP id 2240F56281; Mon, 21 Mar 2005 13:39:24 +0100 (CET) Message-ID: <423EC07B.6080406@mosaic-ag.com> Date: Mon, 21 Mar 2005 13:39:23 +0100 From: Roland Walter User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7.5) Gecko/20041217 X-Accept-Language: de-DE,de,en MIME-Version: 1.0 To: Nico Cc: pgsql-jdbc@postgresql.org Subject: Re: getting a sequence value References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: mosaic-ag.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.117 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/172 X-Sequence-Number: 12564 Nico schrieb: >Table data: >Table 1: >Field1 (integer) default: nextval('public."tblTable1_FieldID_seq"'::text) >other field... >Table 2: >Field1 (integer) default: nextval('public."tblTable2_FieldID_seq"':text) >Field2 (integer) foreign key that references to Field1 in Table 1... > >So when I do this: >INSERT INTO "tblTable1"(other fields...) VALUES(...); >how do I know what to put in here? >INSERT INTO "tblTable2"("Field2", other fields...) VALUES(???, ...); > > > How about INSERT INTO "tblTable2 ("Field2", ...) VALUES (currval('public."TbleTable1_FieldID_seq"'), ...); But you have to do this in the same connection to the database, that did insert into table 1. -- Roland Walter MOSAIC SOFTWARE AG Telefon: 02225/882-411 Fax: 02225/882-201 http://www.mosaic-ag.com