Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 5953 invoked from network); 26 Sep 2005 10:39:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Sep 2005 10:39:49 -0000 Received: (qmail 65695 invoked by uid 500); 26 Sep 2005 10:39:48 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 65360 invoked by uid 500); 26 Sep 2005 10:39:47 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 65349 invoked by uid 99); 26 Sep 2005 10:39:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2005 03:39:46 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.36] (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2005 03:39:53 -0700 Received: from phys-epost-1 ([129.159.136.14]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j8QAdOvD012647 for ; Mon, 26 Sep 2005 04:39:24 -0600 (MDT) Received: from conversion-daemon.epost-mail1.sweden.sun.com by epost-mail1.sweden.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0INF001016675C@epost-mail1.sweden.sun.com> (original mail from Bernt.Johnsen@Sun.COM) for derby-user@db.apache.org; Mon, 26 Sep 2005 12:39:23 +0200 (MEST) Received: from localhost (atum01.Norway.Sun.COM [129.159.112.201]) by epost-mail1.sweden.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0INF00BMA6XNE6@epost-mail1.sweden.sun.com> for derby-user@db.apache.org; Mon, 26 Sep 2005 12:39:23 +0200 (MEST) Date: Mon, 26 Sep 2005 12:39:23 +0200 From: "Bernt M. Johnsen" Subject: Re: Equivalent of SQL "DROP TABLE IF EXISTS MY_TABLE" ? In-reply-to: <20050926100926.GB30511@atum01.norway.sun.com> To: Derby Discussion Message-id: <20050926103923.GA30714@atum01.norway.sun.com> Organization: Sun Microsystems MIME-version: 1.0 Content-type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PEIAKu/WMn1b1Hv9" Content-disposition: inline User-Agent: Mutt/1.5.9i References: <20050926175743.AFC1.WOLFGANG127US@yahoo.co.jp> <20050926100926.GB30511@atum01.norway.sun.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --PEIAKu/WMn1b1Hv9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable >>>>>>>>>>>> Bernt M. Johnsen wrote (2005-09-26 12:09:26): > >>>>>>>>>>>> wolfgang127us@yahoo.co.jp wrote (2005-09-26 18:11:26): > > Hi there, > >=20 > > To initialize my database, I want to use an SQL=20 > > equivalent of "DROP TABLE IF EXISTS MY_TABLE" . > >=20 > > I've tried it but of course didn't work > >=20 > > Does Derby support this kinda SQL or Is there any workaround > > I can drop a table if it exists ?? >=20 > One way could be: > try { > stmt.executeUpdate("DROP TABLE MY_TABLE"); > } catch (SQL_Exception e) { > if (!e.getSQLState().equals("proper SQL-state for table does = not exist")) In Derby it is: if (!e.getSQLState().equals("42Y55")) --=20 Bernt Marius Johnsen, Database Technology Group,=20 Sun Microsystems, Trondheim, Norway --PEIAKu/WMn1b1Hv9 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFDN8/alFBD9TXBAPARAnmSAJ9A7gx5ZUrKnkvJ9rokNxVon5eD8ACg2OL+ dnPLlhK3oNftD9cJxD+pK3c= =vTQ6 -----END PGP SIGNATURE----- --PEIAKu/WMn1b1Hv9--