force command execution

From: drdani(at)mazsola(dot)iit(dot)uni-miskolc(dot)hu
To: pgsql-sql(at)postgresql(dot)org
Subject: force command execution
Date: 2005-04-15 08:33:26
Message-ID: Pine.LNX.4.61.0504151018380.13607@mazsola.iit.uni-miskolc.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

Let's suppose I have a plpgsql function like:

...
begin
alter ...
...;
insert ...
...;
create ...
...;
drop ...;
and lot of such commands in any order...
end;
...

(There is no "perform" keyword.)

Sometimes "ALTER" failes becouse it is already done. Sometimes
"INSERT" failes becouse record already exists. Sometimes "DROP"
failes bacouse object is already dropped by earlier execution of this
function. When any of the command fails function has no effect at all
becouse everything is rolled back.

Is it possible to run this function without rollback effect and just
skip failures? (Server is 8.0.0-rc1.)

If the only way is putting each command in

begin
perform command;
exception
when others then
NULL;
end;

then I'm looking for a text processing tool which can do this
"wrapping" automaticaly. I've too much functions and commands in them,
so hand work is not an option.

Daniel

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephen Quinney 2005-04-15 09:22:27 Combining values in a column
Previous Message Rizal 2005-04-15 06:33:55 Salam Kenal