When can DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK have an effect?
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK is "supposed" to be used
before a transaction, to explicitly set the value on failure.
However, the documentation states that this is more or less the default
behavior anyway?
If a condition occurs for which no handler has been declared, the action
taken depends on the condition class:
For SQLEXCEPTION conditions, the stored program terminates at the
statement that raised the condition, as if there were an EXIT handler. If
the program was called by another stored program, the calling program
handles the condition using the handler selection rules applied to its own
handlers.
But that means COMMIT is never called, so, same effect as having no handler.
I'm not sure how to interpret that. It sounds like the "obvious" thing to
do is exit the stored program, but if a calling program has handlers
telling to do otherwise - perhaps a DECLARE EXIT HANDLER FOR SQLEXCEPTION
CONTINUE - it's not clear to me whether the inside stored program
continues or not, or what the "handler selection rules" are in general.
If this (strange to me) interpretation is the case, then that means if
hypothetically a stored program could assume it was never called by
another stored program, the handler is extraneous, but it ensures
consistent behavior
No comments:
Post a Comment