Efficient Insert statement for one record into multiple tables?

Поиск
Список
Период
Сортировка
От Peter Neu
Тема Efficient Insert statement for one record into multiple tables?
Дата
Msg-id 01cd01c7228a$6680d960$bcc8a8c0@PCMELZER
обсуждение исходный текст
Ответы Re: Efficient Insert statement for one record into multiple  (Roland Walter <roland.walter.rwa@gmx.net>)
Список pgsql-jdbc

Hello,

 

I have this task that I need to insert one user record into to tables A and B.

 

User table A contains primary key and main data. Table B contains extra data for

statistics. Table A has one field Id which is a sequence so it gets a unique value

for each new insert. I would like to insert this value into the other table B as well as

foreign key.

 

So I’d like to do something like this

 

insert into A (user_name, value2 ) values ( “foo”, “foo2”)

 

AND

 

insert into B ( id_from_a , statistic_data) values ( 23, “bla”)

 

How is this done the best way? I would like to do this in one call.

 

Sorry, for his dumb question but I’m not very experienced in Postgresql. :o(

 

 

Cheers,

 

Pete

 

 

 

 

 

 

 

 

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

Предыдущее
От: Mikko Tiihonen
Дата:
Сообщение: Binary resultset patch v6
Следующее
От: Roland Walter
Дата:
Сообщение: Re: Efficient Insert statement for one record into multiple