From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Marc Mamin <M(dot)Mamin(at)intershop(dot)de> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: plpgsql, Exception handling: catching the message ? |
Date: | 2010-11-18 12:57:02 |
Message-ID: | AANLkTikknkay=1LEeDeWdR0n-_sz+Ju=qFt-ut3ZdWcD@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
2010/11/18 Marc Mamin <M(dot)Mamin(at)intershop(dot)de>:
>
> Hello,
>
> In an exception block, we can check the error code.
> Is there a way to get the message and possibly the detail too ?
>
yes, but you need a 8.4 as minimum
http://www.postgresql.org/docs/8.4/interactive/plpgsql-errors-and-messages.html
Regards
Pavel Stehule
>
>
> ereport(ERROR, \
> (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), \
> => errmsg("could not establish connection"), \
> => errdetail("%s", msg))); \
>
>
>
> background: (Version 8.3.12)
> dblink seems to sometimes only provides information of the remote
> exception in the message, with a misleading errcode:
>
>
> select * from dblink_send_query ('c', 'create table my_share4( a
> int)');
> select * from dblink_get_result('c') as t1(f1 text);
>
>
> ERROR: sql error
> DETAIL: ERROR: relation "my_share4" already exists
>
> ********** Error **********
>
> ERROR: sql error
> SQL state: 42601 (<= SYNTAX ERROR)
> Detail: ERROR: relation "my_share4" already exists (=>
> DUPLICATE TABLE)
>
>
>
> best regards,
>
> Marc Mamin
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2010-11-18 13:45:05 | Re: ERROR row is too big size 9336, exceeds size 8160 when populating record with tsquery and tsvector fields |
Previous Message | Marc Mamin | 2010-11-18 12:34:10 | plpgsql, Exception handling: catching the message ? |