THROW Statement

Throws an error, causing code execution to jump to an enclosing CATCH block.

Syntax

THROW;
THROW error-message;

Parameters

  • error-message: text (optional)
    The value to be returned from the ERROR_MESSAGE function. If not provided, then the value from the last thrown error is retained; this allows a CATCH block to re-throw an error without changing it.

Examples

  • THROW 'Oops';
    Throws an error such that ERROR_MESSAGE() returns "Oops".
  • THROW;
    Re-throws the last thrown error without changing it. Do this inside of a CATCH block.