Search Postgresql Archives

Re: plpgsql, Exception handling: catching the message ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2010/11/18 Marc Mamin <M.Mamin@xxxxxxxxxxxx>:
>
> 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@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux