Multiple choice technology databases

Which one of the following is a valid RAISE_APPLICATION_ERROR call?

  1. RAISE_APPLICATION_ERROR(-21001);

  2. RAISE_APPLICATION_ERROR(-20001,'An error has occurred');

  3. RAISE_APPLICATION_ERROR(-21001,'An error has occurred');

  4. RAISE_APPLICATION_ERROR(-20001);

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

RAISE_APPLICATION_ERROR is a built-in PL/SQL procedure that requires two parameters: an error code (must be between -20001 and -20999) and an error message string. Option B is correct with error code -20001 and a message. Option C uses -21001 which is outside the valid range, while options A and D are missing the required message parameter.