pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedHandling SQL errors using libpq
2+ messages / 2 participants
[nested] [flat]
* Handling SQL errors using libpq
@ 2002-11-21 18:37 William Brennan <brennan@unix2.netaxs.com>
2002-11-27 14:15 ` Re: Handling SQL errors using libpq Oliver Elphick <olly@lfix.co.uk>
0 siblings, 1 reply; 2+ messages in thread
From: brennan@unix2.netaxs.com @ 2002-11-21 18:37 UTC (permalink / raw)
To: pgsql-interfaces
I'm new to Postgresql, so please bear with me.
After a call to libpq, I would like to be able to recognize specific
SQL errors which might occur, beyond the simple results obtainable
via a call to PQresultStatus(). I want more precision.
For example, I have a table with a primary key. If I attempt to insert
a new row with a duplicate key, PQresultStatus() rightly returns an
error (PGRES_FATAL_ERROR). However my program has no way to distinguish
from this blunt instrument whether it's a duplicate-key problem, or
any of hundreds of other problems.
How should my program recognize the duplicate-key error? And more
generally, how to I reconize other anticipated SQL errors?
Thanks for your help!
-- Bill
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Handling SQL errors using libpq
2002-11-21 18:37 Handling SQL errors using libpq William Brennan <brennan@unix2.netaxs.com>
@ 2002-11-27 14:15 ` Oliver Elphick <olly@lfix.co.uk>
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Elphick @ 2002-11-27 14:15 UTC (permalink / raw)
To: William Brennan <brennan@unix2.netaxs.com>; +Cc: pgsql-interfaces
On Thu, 2002-11-21 at 18:37, William Brennan wrote:
> After a call to libpq, I would like to be able to recognize specific
> SQL errors which might occur, beyond the simple results obtainable
> via a call to PQresultStatus(). I want more precision.
You can get the actual error message with PQresultErrorMessage()
--
Oliver Elphick <olly@lfix.co.uk>
LFIX Limited
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-11-27 14:15 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-21 18:37 Handling SQL errors using libpq William Brennan <brennan@unix2.netaxs.com>
2002-11-27 14:15 ` Oliver Elphick <olly@lfix.co.uk>
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