Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 8D82C9FA2FD for ; Mon, 18 Dec 2006 05:54:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 88204-07 for ; Mon, 18 Dec 2006 05:54:21 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id E8D2E9FA28E for ; Mon, 18 Dec 2006 05:54:29 -0400 (AST) Received: (qmail invoked by alias); 18 Dec 2006 09:54:26 -0000 Received: from ktbl.heagmedianet.de (EHLO PCMELZER) [213.188.107.46] by mail.gmx.net (mp038) with SMTP; 18 Dec 2006 10:54:26 +0100 X-Authenticated: #17979613 From: "Peter Neu" To: Subject: Efficient Insert statement for one record into multiple tables? Date: Mon, 18 Dec 2006 10:53:39 +0100 Message-ID: <01cd01c7228a$6680d960$bcc8a8c0@PCMELZER> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01CE_01C72292.C8454160" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AcciimTkhT5zWTGjRqazg1oVz1c3Ow== X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200612/81 X-Sequence-Number: 16313 This is a multi-part message in MIME format. ------=_NextPart_000_01CE_01C72292.C8454160 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_01CE_01C72292.C8454160 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

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

 

 

 

 

 

 

 

 

------=_NextPart_000_01CE_01C72292.C8454160--