Re: Anybody have an Oracle PL/SQL reference at hand? - Mailing list pgsql-hackers

From Gavin Sherry
Subject Re: Anybody have an Oracle PL/SQL reference at hand?
Date
Msg-id Pine.LNX.4.58.0408032228220.13632@linuxworld.com.au
Whole thread Raw
In response to Re: Anybody have an Oracle PL/SQL reference at hand?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Anybody have an Oracle PL/SQL reference at hand?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
One other difference when compared with Oracle is that Oracle does not
abort the transaction which raised the exception. Although I generally do
not think this is a great idea, it does allow for things like retry loops.
Assuming we have savepoints, consider the following function which creates
a user account


DECLAREsuffix int;
BEGINsuffix := 1;LOOP    BEGIN;        SAVEPOINT start;        INSERT INTO users VALUES(user || suffix);        EXIT;
EXCEPTION        WHEN UNIQUE_VIOLATION THEN            ROLLBACK TO start;            suffix := suffix + 1;    END;END
LOOP;
END;

Again, it might not be great to leave the database in an inconsistent
state when we get to the exception handler and I'd be all for generating
another exception if the (sub) transaction was not rolled back and the
exception handler tried to access data. Just some ideas.

Gavin


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: How to crash postgres using savepoints
Next
From: Tatsuo Ishii
Date:
Subject: Re: Unicode restriction