From: | "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | plpgsql, Exception handling: catching the message ? |
Date: | 2010-11-18 12:34:10 |
Message-ID: | C4DAC901169B624F933534A26ED7DF31034BB90F@JENMAIL01.ad.intershop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
In an exception block, we can check the error code.
Is there a way to get the message and possibly the detail too ?
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
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2010-11-18 12:57:02 | Re: plpgsql, Exception handling: catching the message ? |
Previous Message | Sim Zacks | 2010-11-18 12:32:54 | restore encoding problem |