Joshua D. Drake wrote:
David Lowe wrote:You would have to put each statement into a savepoint, and catch each error that occured and commit or rollback to a savepointWithin 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?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
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
