Home > Archive > PostgreSQL JDBC > January 2006 > error code invalid_input_syntax









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author error code invalid_input_syntax
Rainer Leo

2006-01-12, 8:24 pm

I wrote a function which generates SQL statements
for INSERTs and UPDATEs, in which I cast the values
to the correct datatype.

Now I want to catch

ERROR: invalid input syntax for integer: "i"

but although I tried quite a few I can't find the right
error code for this exception.

Is it possible that this error can not be caught?


Thanks
Leo



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Kris Jurka

2006-01-12, 8:24 pm



On Thu, 12 Jan 2006, Rainer Leo wrote:

> I wrote a function which generates SQL statements
> for INSERTs and UPDATEs, in which I cast the values
> to the correct datatype.
>
> ERROR: invalid input syntax for integer: "i"
>
> but although I tried quite a few I can't find the right
> error code for this exception.
>


You can easily check the error code via SQLException.getSQLState(). A
quick test in psql will also demonstrate its value.

jurka=# \set VERBOSITY verbose
jurka=# select 'a'::int;
ERROR: 22P02: invalid input syntax for integer: "a"
LOCATION: pg_atoi, numutils.c:84

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com