Re: catch SQLException, error code for Foeign key violation, - Mailing list pgsql-general

From surabhi.ahuja
Subject Re: catch SQLException, error code for Foeign key violation,
Date
Msg-id 8626C1B7EB748940BCDD7596134632BE398677@jal.iiitb.ac.in
Whole thread Raw
In response to catch SQLException, error code for Foeign key violation,  ("surabhi.ahuja" <surabhi.ahuja@iiitb.ac.in>)
Responses Re: catch SQLException, error code for Foeign key violation,  (Kris Jurka <books@ejurka.com>)
List 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@ejurka.com]
Sent: Tue 4/18/2006 4:43 AM
To: surabhi.ahuja
Cc: pgsql-general@postgresql.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

pgsql-general by date:

Previous
From: "Martin Kuria"
Date:
Subject: Categories and Sub Categories (Nested)
Next
From: Achilleus Mantzios
Date:
Subject: Re: Thoughts on a Isolation/Security problem