Re: getting a sequence value

Поиск
Список
Период
Сортировка
От Roland Walter
Тема Re: getting a sequence value
Дата
Msg-id 423EC07B.6080406@mosaic-ag.com
обсуждение исходный текст
Ответ на getting a sequence value  ("Nico" <nicohmail-postgresql@yahoo.com>)
Ответы Re: getting a sequence value  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-jdbc
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


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

Предыдущее
От: Guillaume Cottenceau
Дата:
Сообщение: Re: getting a sequence value
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: getting a sequence value