Emmiting signals

Z PostgreSQL
Přejít na: navigace, hledání

Příkaz SIGNAL

Signal an exception condition. Typ of condition is specified by SQLSTATE value. SQLState class (first two chars from SQLSTATE string) specifies sense of signal:

Class Level
00 success
01 info
02 warning
xx error

SQLSTATE is one from some signal attributies. Others attributies are: message_text, pg_message_hint and pg_message_detail. All unhandled signals are emited to outer block. Unhandled error signals stop statement execution. Isn't possible trap class '00' signals. Explicitly unhandled signals of '01' and '02' class are handled by implicit empty warning procedure handler. This handler can be redefined (explicit NOT FOUND handler).

Syntaxe

SIGNAL (SQLSTATE [VALUE] 'xxxxx'|condition) 
  [SET (message_text|hint|detail) '=' string [, ...]]

RESIGNAL [(SQLSTATE [VALUE] 'xxxxx'|condition)]
  [SET (message_text|hint|detail) '=' string [, ...]]
SIGNAL SQLSTATE '22222' SET message_text = 'some message text', message_detail = 'detailed description';

With RESIGNAL statement we can resignal modified trapped signal. This statement can be only in body of exception handler.