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