Enhanced diagnostics statement

Z PostgreSQL
Přejít na: navigace, hledání
- resignal statement
CREATE OR REPLACE FUNCTION cc()
RETURNS void AS
$$
  BEGIN
    DECLARE frk CONDITION;
    DECLARE brk CONDITION;
    DECLARE x, y, z text;
    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
      BEGIN
        GET STACKED DIAGNOSTICS x = CONDITION_IDENTIFIER, y = RETURNED_SQLSTATE;
        GET STACKED DIAGNOSTICS CONDITION 1 z = MESSAGE_TEXT;
        PRINT 'handler >', x,',', y,',', z;
        GET DIAGNOSTICS x = CONDITION_IDENTIFIER, y = RETURNED_SQLSTATE, z = MESSAGE_TEXT;
        PRINT 'handler >', x,',', y,',', z;
        RESIGNAL SET PG_MESSAGE_DETAIL = 'any detail';
      END;
    PRINT 'start';
    SIGNAL frk;
    SIGNAL SQLSTATE '33333' SET MESSAGE_TEXT = 'err message';
    PRINT 'finish';
  END;
$$ LANGUAGE plpgpsm;
SELECT cc();