Re: Anybody have an Oracle PL/SQL reference at hand?

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anybody have an Oracle PL/SQL reference at hand?
Date: 2004-08-03 12:43:04
Message-ID: Pine.LNX.4.58.0408032228220.13632@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

DECLARE
suffix int;
BEGIN
suffix := 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2004-08-03 12:59:33 Re: Unicode restriction
Previous Message Gavin Sherry 2004-08-03 12:25:08 Re: How to crash postgres using savepoints