Search Postgresql Archives

Re: skip duplicate key error during inserts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/27/06 05:10, Gurjeet Singh wrote:
> On 10/27/06, Ron Johnson <ron.l.johnson@xxxxxxx> 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: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux