Re: sending a block through jdbc - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: sending a block through jdbc
Date
Msg-id alpine.BSO.2.00.1005010959380.24884@leary.csoft.net
Whole thread Raw
In response to sending a block through jdbc  (Maxime Lévesque <maxime.levesque@gmail.com>)
List pgsql-jdbc

On Fri, 30 Apr 2010, Maxime L?vesque wrote:

> I want to drop a constraint if it exists, and not get an error if it
> doesn't exist, ideally I'd get a jdbc error code, and silence the
> 'consrtaint does not exist' exception, but since postgress doesn't send
> error codes to jdbc, I'd like to put the statement in a block and
> silence the exception like this

PG sets SQLState in the SQLException since it is standardized and not
error code which is vendor specific.

>    sb.append("begin \n");
>    sb.append("alter table " + foreingKeyTable.name + " drop
> constraint " + fkName + ";\n");
>    sb.append("exception when true then \n");
>    sb.append("end;");
>
> It seems that this is either unsupported or I have bad syntax....

PG will only support anonymous blocks in the upcoming 9.0 release, and
then with a different syntax.

http://developer.postgresql.org/pgdocs/postgres/sql-do.html

Kris Jurka

pgsql-jdbc by date:

Previous
From: Maxime Lévesque
Date:
Subject: sending a block through jdbc
Next
From: Kris Jurka
Date:
Subject: Re: Very Dangerous bug in XA connection pooling and SL EJBs with jboss-4.2.3 & latest postgresql-8.4-701.jdbc3.jar