pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: X X <junkmbox@yahoo.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq: how to get error code (not message)
Date: Thu, 2 Dec 2004 18:41:15 -0700
Message-ID: <20041203014115.GA5451@winnie.fuhr.org> (raw)
In-Reply-To: <20041202235946.94486.qmail@web51107.mail.yahoo.com>
References: <20041202060648.GA60984@winnie.fuhr.org>
	<20041202235946.94486.qmail@web51107.mail.yahoo.com>

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/



view thread (3+ messages)

Message-ID: <20041203014115.GA5451@winnie.fuhr.org>
Permalink:  ../20041203014115.GA5451@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20041203014115.GA5451@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: mike@fuhr.org, junkmbox@yahoo.com
  Subject: Re: libpq: how to get error code (not message)
  In-Reply-To: <20041203014115.GA5451@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox