FirebirdSQL logo
 SEQUENCE (GENERATOR)COLLATION 

CREATE OR ALTER EXCEPTION

Creates a custom exception if it doesn’t exist, or alters a custom exception

Available in

DSQL

Syntax
CREATE OR ALTER EXCEPTION exception_name '<message>'

!! See syntax of CREATE EXCEPTION for further rules !!

The statement CREATE OR ALTER EXCEPTION is used to create the specified exception if it does not exist, or to modify the text of the error message returned from it if it exists already.If an existing exception is altered by this statement, any existing dependencies will remain intact.

CREATE OR ALTER EXCEPTION Example

Changing the message for the exception E_LARGE_VALUE
CREATE OR ALTER EXCEPTION E_LARGE_VALUE
  'The value is higher than the permitted range 0 to 32,765';

docnext count = 5

DROP EXCEPTION

Drops a custom exception

Available in

DSQL, ESQL

Syntax
DROP EXCEPTION exception_name
Table 1. DROP EXCEPTION Statement Parameter
Parameter Description

exception_name

Exception name

The statement DROP EXCEPTION is used to delete an exception.Any dependencies on the exception will cause the statement to fail, and the exception will not be deleted.

Who Can Drop an Exception

The DROP EXCEPTION statement can be executed by:

  • Administrators

  • The owner of the exception

  • Users with the DROP ANY EXCEPTION privilege

DROP EXCEPTION Examples

Dropping exception E_LARGE_VALUE
DROP EXCEPTION E_LARGE_VALUE;

RECREATE EXCEPTION

Drops a custom exception if it exists, and creates a custom exception

Available in

DSQL

Syntax
RECREATE EXCEPTION exception_name '<message>'

!! See syntax of CREATE EXCEPTION for further rules !!

The statement RECREATE EXCEPTION creates a new exception for use in PSQL modules.If an exception with the same name exists already, the RECREATE EXCEPTION statement will try to drop it and create a new one.If there are any dependencies on the existing exception, the attempted deletion fails and RECREATE EXCEPTION is not executed.

RECREATE EXCEPTION Example

Recreating the E_LARGE_VALUE exception
RECREATE EXCEPTION E_LARGE_VALUE
  'The value exceeds its limit';