Re: catch SQLException, error code for Foeign key violation,

From: "surabhi(dot)ahuja" <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in>
To: "Kris Jurka" <books(at)ejurka(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: catch SQLException, error code for Foeign key violation,
Date: 2006-04-19 06:32:54
Message-ID: 8626C1B7EB748940BCDD7596134632BE398677@jal.iiitb.ac.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks .
in java i can catch SQL Exception,

what is the way to capture such exception in Cpp,
are there any examples available for this?

right now in cpp, i do this

rStatus = PQresultStatus(result);

but what is the specific error code, how to get that,

thanks,
regards
Surabhi

________________________________

From: Kris Jurka [mailto:books(at)ejurka(dot)com]
Sent: Tue 4/18/2006 4:43 AM
To: surabhi.ahuja
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] catch SQLException, error code for Foeign key violation,

***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********

On Mon, 17 Apr 2006, surabhi.ahuja wrote:

> The question is that is from this SQLException can i detect if it is a
> foreign key violation,
>

You should check the value of SQLException.getSQLState() against this
table:
http://www.postgresql.org/docs/8.1/static/errcodes-appendix.html

Kris Jurka

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kris Jurka 2006-04-19 06:42:28 Re: catch SQLException, error code for Foeign key violation,
Previous Message Martin Kuria 2006-04-19 05:44:35 Categories and Sub Categories (Nested)