pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Maxime Lévesque <maxime.levesque@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: sending a block through jdbc
Date: Sat, 1 May 2010 10:02:55 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.1005010959380.24884@leary.csoft.net> (raw)
In-Reply-To: <741db998-8a4f-4442-930f-46821ff785d2@b18g2000yqb.googlegroups.com>
References: <741db998-8a4f-4442-930f-46821ff785d2@b18g2000yqb.googlegroups.com>



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



view thread (3+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1005010959380.24884@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1005010959380.24884@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1005010959380.24884@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, maxime.levesque@gmail.com
  Subject: Re: sending a block through jdbc
  In-Reply-To: <alpine.BSO.2.00.1005010959380.24884@leary.csoft.net>
  References: <741db998-8a4f-4442-930f-46821ff785d2@b18g2000yqb.googlegroups.com> <alpine.BSO.2.00.1005010959380.24884@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox