Re: How to tell why an insert failed? - Mailing list pgsql-general

From Tom Lane
Subject Re: How to tell why an insert failed?
Date
Msg-id 11327.1025043821@sss.pgh.pa.us
Whole thread Raw
In response to How to tell why an insert failed?  (Jeremy Cowgar <develop@cowgar.com>)
List pgsql-general
Jeremy Cowgar <develop@cowgar.com> writes:
> In C I would like to tell if an insert failed and why. In particular if
> it failed because of a duplicate value in a field marked unique.

Right now, the only way to tell this is to look at the error message
(PQerrorMessage), which will say something like

ERROR:  Cannot insert a duplicate key into unique index foo_f1_key

This is pretty grotty, but until we get around to supporting proper
error codes, it's the only way ...

            regards, tom lane



pgsql-general by date:

Previous
From: Elaine Lindelef
Date:
Subject: What is a tuple?
Next
From: "Jeff MacDonald"
Date:
Subject: Re: Advocacy Idea.