Re: [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions

2017-09-21 Thread Pavel Stehule
DECLARE >> >> >> v_msg TEXT := '''SOMETHING IS WRONG'''; >> >> v_sqlstate TEXT := '''E0001'''; >> >> v1 TEXT ; >> >> >> BEGIN >> >> v1 := v_msg || ' USING errcode = ' || v_sqlstate; >> >> RAISE NOTICE '%', v1; >> >> RAISE EXCEPTION '%', v1; >> >> >> EXCEPTION >> >> WHEN SQLSTATE 'E0001'

Re: [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions

2017-09-21 Thread Tom Lane
mike davis 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

Re: [GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions

2017-09-21 Thread Pavel Stehule
2017-09-22 1:40 GMT+02:00 mike davis : > 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. In this way the customer error codes and >

[GENERAL] Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions

2017-09-21 Thread mike davis
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. In this way the customer error codes and message are not hard coded into code and are defined consistently in one