Es gibt kein Äquivalent von FINALLY
, aber Sie können es mit verschachtelten PL/SQL-Blöcken simulieren;
DECLARE
-- Your variables.
return_early BOOLEAN := FALSE;
BEGIN
-- Do something
DECLARE
-- Local variables in "try" block
BEGIN
-- Equivalent of "try" block
-- Do something that may raise an exception
IF some_condition THEN
return_early := TRUE;
-- you could also use "GOTO end_try;" rather than surrounding the
-- following statements in an "ELSE" statement
ELSE
-- Do something else that may raise an exception
END IF;
EXCEPTION
WHEN your_exception THEN
-- Equivalent of "catch" block
END;
<<end_try>>
-- Handle "finally" here, after end of nested block.
-- Note: you can only see variables declared in this outer block
-- not variables local to the nested PL/SQL block.
IF return_early THEN
RETURN;
END IF;
-- Continue and do more stuff.
END;
/
Im Gegensatz zu Java unterstützt PL/SQL keinen Abschnitt FINALLY. Sie können jedoch viel von dem, was dieser Abschnitt tut, emulieren. Überprüfen Sie diese http://www.oracle.com/technetwork/testcontent/o19plsql-085133.html und diese http://stevenfuersteinonplsql.blogspot.com/2017/01/emulating-finally-clause-in-plsql.html –