I\'m trying to do some checkings on a DB schema at the beginning of a PL/SQL script.
If the checkings give unsuccessful results, I want to stop the script, to prevent th
If you don't want to raise an exception, you could try something like (untested):
declare
SOME_COUNT INTEGER;
begin
SELECT COUNT(*) INTO SOME_COUNT FROM SOME_TABLE WHERE ;
IF (SOME_COUNT > 0) THEN
DBMS_OUTPUT.PUT_LINE('Test failed, I don''want the rest of the script'
|| ' to be executed.');
goto end_proc;
END IF;
-- A bunch of great code here
<>
null; -- this could be a commit or other lines of code
end;
Some people hate any GOTO statements as they can lead to spaghetti code if abused, but in simple situations like this (again, assuming you don't want to raise an exception) they work well imo.