Re: Efficient Insert statement for one record into multiple

From: Roland Walter <roland(dot)walter(dot)rwa(at)gmx(dot)net>
To: Peter Neu <peter(dot)neu(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Efficient Insert statement for one record into multiple
Date: 2006-12-18 14:30:12
Message-ID: 4586A5F4.7070305@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

-----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-----

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albe Laurenz 2006-12-18 14:36:50 Re: Efficient Insert statement for one record into multiple
Previous Message Dave Cramer 2006-12-18 12:29:32 Re: Efficient Insert statement for one record into multiple