From: | "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com> |
---|---|
To: | "Ron Johnson" <ron(dot)l(dot)johnson(at)cox(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: skip duplicate key error during inserts |
Date: | 2006-10-27 09:41:48 |
Message-ID: | 65937bea0610270241g41a7c8dbr85f7edb9ddc70df@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
If you are using psql, I'd recommend using '\set ON_ERROR_ROLLBACK on'.
HTH
--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | yahoo }.com
On 10/22/06, Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 10/22/06 04:39, Jeffrey Webster wrote:
> > On 10/20/06, Jean-Christophe Roux <jcxxr(at)yahoo(dot)com> wrote:
> >>
> >> Hello,
> >> [snip]
> >>
> >
> >
> >
> > none of them will be inserted because the first insert is a primary key
> >> violation. How can I have postgreSQL not mind about the error and
> >> proceed to
> >> the next insert. I could send the inserts one at a time but bundling
> them
> >> speeds up the process.
> >> Thanks
> >>
> >>
> > I feel your pain... However, there is no way to do this
> (currently?). Some
> > possible solutions had been suggested some time back by a colleague, but
> > they were rejected. It requires a source code change (and not a simple
> > one,
> > at that) to implement.
> >
> > Until a concensus is reached by the primary contributors there is no
> easy
> > answer.
> >
> > We've resorted to batch loading and parsing error messages to load all
> data
> > between primary key violations. It's still considerably more efficient
> > than
> > single inserts.
> >
> > (we've got the code to accomplish what you're asking about in the
> attic...
> > hopefully something will come of it some day.)
>
> The generalized version of this issue (transaction totally fails on
> any error) is extremely painful.
>
> Most RDBMSs (well, ok, the other RDBMSs that *I* have worked with)
> don't do that, and there's a lot of code written in the form:
>
> INSERT INTO ...
> IF PK-ERROR THEN
> UPDATE
> END-IF.
>
> - --
> Ron Johnson, Jr.
> Jefferson LA USA
>
> Is "common sense" really valid?
> For example, it is "common sense" to white-power racists that
> whites are superior to blacks, and that those with brown skins
> are mud people.
> However, that "common sense" is obviously wrong.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (GNU/Linux)
>
> iD8DBQFFO0buS9HxQb37XmcRAughAKCrD6o+ibwr7fclE+wBXnUgX3tNDwCgw8Or
> 5rGcfhYoAH8giSjwwSqHJe8=
> =aczL
> -----END PGP SIGNATURE-----
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-10-27 09:43:26 | Re: what is the default username password for PostgreSQL, which was installed with FC5. |
Previous Message | Purusothaman A | 2006-10-27 09:31:09 | Re: what is the default username password for PostgreSQL, which was installed with FC5. |