Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BDBF6632820 for ; Sat, 1 May 2010 11:03:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09986-02 for ; Sat, 1 May 2010 14:02:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 73DE56327B9 for ; Sat, 1 May 2010 11:02:57 -0300 (ADT) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 9F0FA28420; Sat, 1 May 2010 10:02:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=AarDX6pSvKeu/sqbr8Q3Zxr8anY=; b=MXst97 wm5pFER50Ky6AM0zuK7p/noHIt/YAFCKM0pSIDA8xI4iX4mk0EPOnJf9QHcq3hAl 1G2HRiB74pUa45WsHcwsWUcvUEmurArspoBKBLIuW2pPDP6yjtS34Ux9cbvZ6q+G Dbi5FpXVaeDJ5koVUNZnvHV3LHS8/Ea7nFOxI= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 9B91F28404; Sat, 1 May 2010 10:02:55 -0400 (EDT) Received: by leary.csoft.net (Postfix, from userid 1112) id 838C4A388; Sat, 1 May 2010 10:02:55 -0400 (EDT) Date: Sat, 1 May 2010 10:02:55 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: =?ISO-8859-15?Q?Maxime_L=E9vesque?= cc: pgsql-jdbc@postgresql.org Subject: Re: sending a block through jdbc In-Reply-To: <741db998-8a4f-4442-930f-46821ff785d2@b18g2000yqb.googlegroups.com> Message-ID: References: <741db998-8a4f-4442-930f-46821ff785d2@b18g2000yqb.googlegroups.com> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/2 X-Sequence-Number: 20486 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