Re: getting a sequence value - Mailing list pgsql-jdbc

From Nico
Subject Re: getting a sequence value
Date
Msg-id d1muiq$1r37$1@news.hub.org
Whole thread Raw
In response to getting a sequence value  ("Nico" <nicohmail-postgresql@yahoo.com>)
List pgsql-jdbc
Thank you,
Nico.

"Roland Walter" <rwa@mosaic-ag.com> schreef in bericht
news:423EC07B.6080406@mosaic-ag.com...
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>      joining column's datatypes do not match
>



pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: getting a sequence value
Next
From: David Gagnon
Date:
Subject: Is that normal I can't commit a transaction when using refcursor in a stored procedure