Joshua D. Drake wrote:
> David Lowe wrote:
>> Within the context of a script, executing:
>>
>> Begin
>> Statement1
>> Statement2
>> Statement3
>> Commit
>>
>> Where I only wish to commit if the error is specific to the object
>> already existing, and rollback for all other errors, what's the best way
>> to accomplish that?
>>
> You would have to put each statement into a savepoint, and catch each
> error that occured and commit or rollback to a savepoint
> based on that result.
You could write a plpgsql function that executes a text given to it
as a parameter, and catches only "already exists" errors. Then your
schema script could look like
select execute_ignoreexists('create table ...') ;
select execute_ignoreexists('create index ...') ;
...
greetings, Florian Pflug