| From: | Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru> | 
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | User defined exceptions | 
| Date: | 2015-07-15 14:10:18 | 
| Message-ID: | [email protected] | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
Hello all!
Trying to emulate "named" user defined exception with:
CREATE OR REPLACE FUNCTION exception_aaa ()  RETURNS text AS $body$
BEGIN
    return 31234;
END;
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;
do $$
begin
    raise exception using errcode=exception_aaa();
exception
    when  sqlstate exception_aaa()
    then
       raise notice 'got exception %',sqlstate;
end;
$$
Got:
ERROR:  syntax error at or near "exception_aaa"
LINE 20: sqlstate exception_aaa()
I looks like "when sqlstate exception_aaa()" doesn't work.
How can I catch exception in this case?
-- 
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2015-07-15 14:22:14 | Re: User defined exceptions | 
| Previous Message | David G. Johnston | 2015-07-09 23:18:49 | Re: How to insert a carriage return and line field between fields in a query |