Re: skip duplicate key error during inserts - Mailing list pgsql-general

From Ron Johnson
Subject Re: skip duplicate key error during inserts
Date
Msg-id 4541E7FC.5050909@cox.net
Whole thread Raw
In response to Re: skip duplicate key error during inserts  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Responses Re: skip duplicate key error during inserts  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
List pgsql-general
On 10/27/06 05:10, Gurjeet Singh wrote:
> On 10/27/06, Ron Johnson <ron.l.johnson@cox.net> wrote:
>
> That doesn't help at all during multi-table transactions
>
>
> What problem do you think you would face in multi-table scenario? I tried
> the following and it worked for me; hope this is what you meant by
> multi-table transactions:
>
> postgres=# begin;
> BEGIN
> postgres=# create table t1 ( a int primary key );
[snip]
> postgres=# commit;
> COMMIT
> postgres=# select * from t1;
> a
> ---
> 1
> (1 row)
>
> postgres=# select * from t2;
> a
> ---
> 1
> (1 row)
>
> postgres=#

Dueling examples.  Attached are two examples of errors.

BTW, PG 8.1.5.

> want the loader to kick duplicates out to an
>> exception file.
>>
>
> Now you are asking for a completely new feature!!!

But easily doable if errors don't puke a transaction.

--
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.
toll_archive=# begin;
BEGIN
Time: 0.124 ms
toll_archive=# create table foo (f1 int primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
CREATE TABLE
Time: 281.424 ms
toll_archive=# commit;
COMMIT
Time: 15.864 ms
toll_archive=# begin;
BEGIN
Time: 0.204 ms
toll_archive=# insert into foo (1);
ERROR:  syntax error at or near "1" at character 18
LINE 1: insert into foo (1);
                         ^
toll_archive=# insert into foo values (1);
ERROR:  current transaction is aborted, commands ignored until end of transaction block
toll_archive=# insert into foo values (1);
INSERT 0 1
Time: 0.985 ms
toll_archive=# insert into foo values (2);
INSERT 0 1
Time: 0.233 ms
toll_archive=# insert into foo values (3);
INSERT 0 1
Time: 0.230 ms
toll_archive=# insert into foo values (1);
ERROR:  duplicate key violates unique constraint "foo_pkey"
toll_archive=# insert into foo values (4);
ERROR:  current transaction is aborted, commands ignored until end of transaction block

Attachment

pgsql-general by date:

Previous
From: "Gurjeet Singh"
Date:
Subject: Re: skip duplicate key error during inserts
Next
From: "chris smith"
Date:
Subject: Re: what is the default username password for PostgreSQL, which was installed with FC5.