Re: [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions
От | Tom Lane |
---|---|
Тема | Re: [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions |
Дата | |
Msg-id | 29032.1506056047@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcodedcustom exceptions (mike davis <mike.davis65@hotmail.com>) |
Ответы |
[GENERAL] Re: Dynamic use of RAISE with USING to generate and catchnon-hardcoded custom exceptions
|
Список | pgsql-general |
mike davis <mike.davis65@hotmail.com> writes: > I'm trying to get dynamic version of the RAISE command working so > that I can use a table of custom application error messages and codes > for use by all developed plpgsql functions. This works for me: DO $$ DECLARE v_msg TEXT := 'SOMETHING IS WRONG'; v_sqlstate TEXT := 'E0001'; BEGIN RAISE EXCEPTION USING message = v_msg, errcode = v_sqlstate; EXCEPTION WHEN SQLSTATE 'E0001' THEN RAISE NOTICE '%','Error E0001 raised - going to do something about it'; WHEN OTHERSTHEN RAISE NOTICE 'OTHER ERRORS: %,%', sqlstate,sqlerrm; END$$; NOTICE: Error E0001 raised - going to do something about it Or you could do RAISE EXCEPTION SQLSTATE v_sqlstate USING message = v_msg; regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
В списке pgsql-general по дате отправления: