From: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
---|---|
To: | Verena Ruff <lists(at)triosolutions(dot)at>, <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: error handling |
Date: | 2006-05-10 14:04:14 |
Message-ID: | C0876B1E.B45D%sdavis2@mail.nih.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 5/10/06 9:35 AM, "Verena Ruff" <lists(at)triosolutions(dot)at> wrote:
> Hello,
>
> sorry for answering so late, ...
>> I do not know if there is an specific error handler built in postgresql
>> (besides error-codes).
>>
>> If you break the unique constraint an error will be thrown. A
>> workaround may be to launch a trigger BEFORE the insertion and do whatever is
>> necessary within the trigger.
>>
> This is possibillity I was thinking of, too. But if there are many
> inserts and (probably) only a few of them would break the unique
> constraint, there would be a great overhead. This was what I'd like to
> avoid with a custom error handler.
Probably the simplest way to do this is to load the data into a temporary
table without the unique constraint then use SQL to insert a "clean" version
into the new table. Alternatively, you could use savepoints. If an insert
fails, just rollback to that savepoint. If it succeeds, commit that
savepoint.
Sean
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Davis | 2006-05-10 15:23:36 | Re: index not used with inherited tables |
Previous Message | Verena Ruff | 2006-05-10 13:35:06 | Re: error handling |