pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Peter Neu <peter.neu@gmx.net>
Cc: pgsql-jdbc@postgresql.org
Cc: 'Roland Walter' <roland.walter.rwa@gmx.net>
Subject: Re: Efficient Insert statement for one record into multiple
Date: Tue, 19 Dec 2006 06:09:47 -0500
Message-ID: <30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com> (raw)
In-Reply-To: <00f201c72357$0ba220d0$bcc8a8c0@PCMELZER>
References: <00f201c72357$0ba220d0$bcc8a8c0@PCMELZER>

If you create the key using nextval you will never get duplicate key  
exceptions.

However, you should never close connections in the catch clause.  
Always close connections in a finally clause.

Dave
On 19-Dec-06, at 5:18 AM, Peter Neu wrote:

> Hello,
>
> the insertion within the same connection objects works just fine. ;o)
> One thing which still keeps me thinking is how should I handle  
> duplicate
> key exceptions when it happens in the first insert? Should I just  
> close
> the connection object in the catch clause when this happens in the  
> first
> statement so the second statement hits an  
> AlreadyClosedConnectionException?
>
> Cheers,
> Pete
>
>
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that  
> your
>        message can get through to the mailing list cleanly
>




view thread (13+ messages)

Message-ID: <30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com>
Permalink:  ../30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com/
Also on:    postgresql.org/message-id/30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, peter.neu@gmx.net, roland.walter.rwa@gmx.net
  Subject: Re: Efficient Insert statement for one record into multiple
  In-Reply-To: <30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com>
  References: <00f201c72357$0ba220d0$bcc8a8c0@PCMELZER> <30DA21B9-0758-4A54-BC35-D955A2D95B83@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox