Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
38
Добавлен:
18.03.2015
Размер:
608.7 Кб
Скачать

SQL Language Enhancements

...

WHEN SQLCODE -802 DO EXCEPTION E_EXCEPTION_1;

WHEN SQLCODE -803 DO EXCEPTION E_EXCEPTION_2;

WHEN ANY DO

EXECUTE PROCEDURE P_ANY_EXCEPTION(SQLCODE);

END

See also the EXCEPTION HANDLING ENHANCEMENTS, below, and the document README.exception_handling in the firebird2/doc/sql.extensions branch of the Firebird CVS tree.

INSERTING, UPDATING and DELETING

Three pseudo-Boolean expressions that can be tested to determine the type of DML operation being executed. Available in PSQL, only in triggers. Intended for use with multi-action triggers (see the DML section, above).

Syntax Pattern

INSERTING

UPDATING

DELETING

Example

IF (INSERTING OR UPDATING) THEN

BEGIN

IF(NEW.SERIAL_NUM IS NULL) THEN

NEW.SERIAL_NUM = GEN_ID(G_GENERATOR_1, 1);

(1.5) Enhancements to Exception Handling in PSQL

Dmitry Yemanov

The common syntax for an EXCEPTION statement in PSQL is:

EXCEPTION [name [value]];

The enhancements in 1.5 allow you to

1.define a run-time message for a named exception

2.re-initiate (re-raise) a caught exception within the scope of the exception block

3.Obtain a numeric error code for a caught exception

44

SQL Language Enhancements

1) Run-time exception messaging

Syntax Pattern

EXCEPTION <exception_name> <message_value>;

Examples

a)

EXCEPTION E_EXCEPTION_1 'Error!';

b)

EXCEPTION

E_EXCEPTION_2 'Wrong type for record with ID=' || new.ID;

2) Re-raising an exception

Note

This has no effect outside an exception block.

Syntax Pattern

EXCEPTION;

Examples

a)

BEGIN

...

WHEN SQLCODE -802 DO EXCEPTION E_ARITH_EXCEPT;

WHEN SQLCODE -802 DO EXCEPTION E_KEY_VIOLATION;

WHEN ANY THEN

EXCEPTION;

END

b)

WHEN ANY DO

BEGIN

45

Соседние файлы в папке doc