Re: How to tell why an insert failed?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeremy Cowgar <develop(at)cowgar(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to tell why an insert failed?
Date: 2002-06-25 22:23:41
Message-ID: 11327.1025043821@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeremy Cowgar <develop(at)cowgar(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Elaine Lindelef 2002-06-25 22:39:20 Re: Advocacy Idea.
Previous Message Elaine Lindelef 2002-06-25 21:40:03 What is a tuple?