PL/SQL: is there an instruction to completely stop the script execution?

后端 未结 4 971
孤独总比滥情好
孤独总比滥情好 2021-02-13 16:23

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

4条回答
  •  情话喂你
    2021-02-13 17:08

    A few more seconds of googling gave me the answer: the function RAISE_APPLICATION_ERROR()

      IF (SOME_COUNT > 0) THEN
        RAISE_APPLICATION_ERROR(-20000, 'Test failed');
      END IF;
    

    The user-defined error code should be between -20000 and -20999.

    Details on Oracle doc here: http://docs.oracle.com/cd/B10501_01/appdev.920/a96624/07_errs.htm#877 (section Defining Your Own Error Messages: Procedure RAISE_APPLICATION_ERROR)

提交回复
热议问题