Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D19DF9FA280 for ; Mon, 18 Dec 2006 10:30:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 86013-02 for ; Mon, 18 Dec 2006 10:30:18 -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 3E1BA9F9357 for ; Mon, 18 Dec 2006 10:30:18 -0400 (AST) Received: (qmail invoked by alias); 18 Dec 2006 14:30:13 -0000 Received: from xdsl-213-196-246-72.netcologne.de (EHLO [192.168.3.10]) [213.196.246.72] by mail.gmx.net (mp020) with SMTP; 18 Dec 2006 15:30:13 +0100 X-Authenticated: #2870507 Message-ID: <4586A5F4.7070305@gmx.net> Date: Mon, 18 Dec 2006 15:30:12 +0100 From: Roland Walter User-Agent: Thunderbird 1.5.0.8 (X11/20060911) MIME-Version: 1.0 To: Peter Neu CC: pgsql-jdbc@postgresql.org Subject: Re: Efficient Insert statement for one record into multiple References: <01fa01c7229b$104e2320$bcc8a8c0@PCMELZER> In-Reply-To: <01fa01c7229b$104e2320$bcc8a8c0@PCMELZER> X-Enigmail-Version: 0.94.1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/85 X-Sequence-Number: 16317 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Peter Neu wrote: > Hi, > > in my create table statement I got this line: > > id int4 DEFAULT nextval('public.user_auth_id2_seq'::text) > > So according to your suggestions this would be > > insert into B (id_from_a, statistic_data) values( > currval("public.user_auth_id2_seq"),bla") > > ,right? > Yes. (But beware, I forgot the double-qoute in front of bla.) > If I got you right I cannot link this two insert statements together. > So I need two times to open a prepared statement and execute it. > Would I need to do this in a transaction or is it safe to do this > without it? As Dave Cramer wrote already, you must use the same connection object. If you put in a transaction depends of your application. If you do many insertions in table A and B at the same time, you should put all insertions in one transaction to avoid performance issues. Regards, Roland. - -- Dipl.-Phys. Roland Walter mailto: roland (dot) walter (dot) rwa (at) gmx (dot) net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFFhqX0xoOEAkary1ERAoVPAJ4krT4+7k8YnzX3cRgmqTd9bMllawCfVJuo KIHe0I0jK0lgwcuhJvy4ztc= =T1t5 -----END PGP SIGNATURE-----