Re: libpq: how to get error code (not message) - Mailing list pgsql-interfaces

From Michael Fuhr
Subject Re: libpq: how to get error code (not message)
Date
Msg-id 20041203014115.GA5451@winnie.fuhr.org
Whole thread Raw
In response to Re: libpq: how to get error code (not message)  (Michael Fuhr <mike@fuhr.org>)
List pgsql-interfaces
On Thu, Dec 02, 2004 at 03:59:46PM -0800, X X wrote:

> > I think you're looking for PQresultErrorField()
> > called with the
> > fieldcode argument set to PG_DIAG_SQLSTATE.
>
> Thanks for your reply. This is exactly what I was
> looking for, but the libpq documentation does not
> mention it (at least I did not find).

Appendix A says:
   All messages emitted by the PostgreSQL server are assigned   five-character error codes that follow the SQL
standard's  conventions for "SQLSTATE" codes. 
 

The PQresultErrorField() function is documented in the libpq
"Command Execution Functions" section:

http://www.postgresql.org/docs/7.4/static/libpq-exec.html#AEN20619

The documentation says:
   The following field codes are available:   ...
   PG_DIAG_SQLSTATE       The SQLSTATE code for the error (see Appendix A). Not localizable.Always present.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-interfaces by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: libpq: how to get error code (not message)
Next
From: "Gaetano Sferra"
Date:
Subject: jdbc and refcursor problem