0
Javaの場合と同様に、最終的にすべての条件で実行されるブロックがあります。Oracle PL/SQLブロックのfinallyブロック(JAVA)に似ています
Oracle PL/SQLには、return文を使用してもプロシージャの実行が完了するたびに実行される類似の関数はありますか?
Javaの場合と同様に、最終的にすべての条件で実行されるブロックがあります。Oracle PL/SQLブロックのfinallyブロック(JAVA)に似ています
Oracle PL/SQLには、return文を使用してもプロシージャの実行が完了するたびに実行される類似の関数はありますか?
FINALLY
に相当するものはありませんが、ネストしたPL/SQLブロックを使用してシミュレーションできます。
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;
/
Javaと異なり、PL/SQLはFINALLYセクションをサポートしていません。ただし、このセクションの内容の多くをエミュレートすることはできます。 http://www.oracle.com/technetwork/testcontent/o19plsql-085133.htmlおよびhttp://stevenfeuersteinonplsql.blogspot.com/2017/01/emulation-finally-clause-in-plsql.htmlを参照してください。 –