Thread: EXCEPTION idea

EXCEPTION idea

From
"frank_lupo@email.it"
Date:
This is a method to create/drop/alter EXCEPTION in iterbase db.
This is a good idea for postgresql.
===================
CREATE EXCEPTION

Creates a used-defined error and associated message for use in stored
procedures and triggers. Available in DSQL and isql.

Syntax    CREATE EXCEPTION name 'message';

Important    In SQL statements passed to DSQL, omit the terminating
semicolon. In isql, the semicolon is a terminating symbol for the
statement, so it must be included.

Argument     Description
name    Name associated with the exception message; must be unique
among exception names in the database
'message'    Quoted string containing alphanumeric characters and
punctuation; maximum length = 78 characters.
�

Description    CREATE EXCEPTION creates an exception, a user-defined
error with an associated message. Exceptions may be raised in triggers
and stored procedures.

Exceptions are global to the database. The same message or set of
messages is available to all stored procedures and triggers in an
application. For example, a database can have English and French
versions of the same exception messages and use the appropriate set as
needed.
When raised by a trigger or a stored procedure, an exception:

n    Terminates the trigger or procedure in which it was raised and
undoes any actions performed (directly or indirectly) by it.
n    Returns an error message to the calling application. In isql,
the error message appears on the screen, unless output is redirected.

Exceptions may be trapped and handled with a WHEN statement in a stored
procedure or trigger.

Examples    This isql statement creates the exception,
UNKNOWN_EMP_ID:

CREATE EXCEPTION UNKNOWN_EMP_ID 'Invalid employee number or project
id.';

The following statement from a stored procedure raises the previously
created exception when SQLCODE -530 is set, which is a violation of a
FOREIGN KEY constraint:

. . .
    WHEN SQLCODE -530 DO
        EXCEPTION UNKNOWN_EMP_ID;
. . .

===================
ALTER EXCEPTION

Changes the message associated with an existing exception. Available in
DSQL and isql.

Syntax    ALTER EXCEPTION name 'message'

Argument     Description
name    Name of an existing exception message
'message'    Quoted string containing ASCII values
�

Description    ALTER EXCEPTION changes the text of an exception error
message.

An exception can be altered by its creator, the SYSDBA user, and any
users with operating system root privileges.

Example    This isql statement alters the message of an exception:

ALTER EXCEPTION CUSTOMER_CHECK 'Hold shipment for customer remittance.';

===================
DROP EXCEPTION

Deletes an exception from a database. Available in DSQL and isql.

Syntax    DROP EXCEPTION name

Argument     Description
name    Name of an existing exception message
�

Description    DROP EXCEPTION removes an exception from a database.

Exceptions used in existing procedures and triggers cannot be dropped.

Tip    In isql, SHOW EXCEPTION displays a list of exceptions'
dependencies, the procedures and triggers that use the exceptions.

An exception can be dropped by its creator, the SYSDBA user, and any
user with operating system root privileges.

Example    This isql statement drops an exception:

DROP EXCEPTION UNKNOWN_EMP_ID;

Bye !!
Frank Lupo (Wolf) !!



--
Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f

Sponsor:
PC portatili a partire da 400?: Trovali su eBay!

Clicca qui: http://adv2.email.it/cgi-bin/foclick.cgi?mid=530&d=3-6