samedi 21 novembre 2020

Oracle PL/SQL - Exit begin end block if condition is not met

Is it possible to exit/skip from a begin end block if a condition is not met?

Example:

DECLARE
    my_var BOOLEAN := TRUE;

BEGIN
    IF my_var THEN
        EXIT_BEGIN_END_HERE;  -- Exits the block but continue execution after it!
    END IF;

    -- Other stuff happens here. Won't be executed if IF above is true
    INSERT INTO asdf
    VALUES ('asdf', 'asdf');
END;

-- Other stuff happens here

Aucun commentaire:

Enregistrer un commentaire