Генерация пользовательского кода завершения
Синтаксис
raise_error(< код >)
< код >
– целочисленное значение из диапазона от 10200 до 10999 (включительно).
Описание
Функция завершает текущую исполняемую процедуру или триггер и выставляет указанный < код >
в качестве кода завершения всего запроса, т.е. запроса execute
на запуск процедуры или SQL-оператора, инициировавшего запуск триггера. Это позволяет, в частности, выполнить в триггере откат SQL-запроса, вернув соответствующий пользовательский код завершения.
Возвращаемое значение
Заданный код завершения.
Примеры
1) create or replace procedure proc_re1(in i integer; out res integer) result integer for debug declare exception DIVZERO for DIVZERO; // var ch int; // code res:=50; // ch:=100/i; // res:=res/2; // return ch; // exceptions when DIVZERO then raise_error (10333); // end; call proc_re1(0); [Linter Code 10333] Native error 10333 2) create or replace procedure proc_re1(in i integer; out res integer) for debug declare var ch int; // code res:=20*i; // if res < 100 then raise_error (10555); // endif; // end; 3) execute block result int declare var S int; // var I int; // var c cursor(i int); // code open c for "select max(personid) from auto;"; // S := c.i + 1; // close c; // I := 0; // while (I < S) loop I := I + 1; // raise_error(10299); // endloop; // return 0; // exceptions when all then resignal; // Error to up end; [Linter Code 10299] Native error 10299 4) execute block result int declare var S int; // var I int; // var c cursor(i int); // code open c for "select max(personid) from auto;"; // S := c.i + 1; // close c; // I := S/0; // return S; // exceptions when all then raise_error(10299); // Error to up end; [Linter Code 10299] Native error 10299