getting a sequence value

Поиск
Список
Период
Сортировка
От Nico
Тема getting a sequence value
Дата
Msg-id d1mb4u$1j89$1@news.hub.org
обсуждение исходный текст
Ответы Re: getting a sequence value  (Dave Cramer <pg@fastcrypt.com>)
Re: getting a sequence value  (Roland Walter <rwa@mosaic-ag.com>)
Список pgsql-jdbc
Hi,
I have two tables where the second table has a foreign key to the first one.
When I insert a row in the first one, I need the value of the ID generated
by a sequence in the first table to insert it in the foreign key column in
the second table. Except I don't know how to do this in Java/PostgreSQL...
Anyone knows how?
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(???, ...);

I know in MS SQL server and Oracle one uses an old and new resultset to
resolve this issue, but haven't a clue how to do this in Java/PostgreSQL...

Nico.



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: [Patch] JDBC3 Blob support
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: getting a sequence value