From derby-user-return-6627-apmail-db-derby-user-archive=db.apache.org@db.apache.org Wed Apr 18 00:09:43 2007 Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 74679 invoked from network); 18 Apr 2007 00:09:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2007 00:09:42 -0000 Received: (qmail 29033 invoked by uid 500); 18 Apr 2007 00:09:48 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 29005 invoked by uid 500); 18 Apr 2007 00:09: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 28994 invoked by uid 99); 18 Apr 2007 00:09:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2007 17:09:47 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: 32.97.182.143 is neither permitted nor denied by domain of Stan.Bradbury@gmail.com) Received: from [32.97.182.143] (HELO e3.ny.us.ibm.com) (32.97.182.143) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2007 17:09:40 -0700 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id l3HN816W008733 for ; Tue, 17 Apr 2007 19:08:01 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l3I08tjJ536038 for ; Tue, 17 Apr 2007 20:08:55 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l3I08nF4029137 for ; Tue, 17 Apr 2007 20:08:49 -0400 Received: from [127.0.0.1] (bradbury-lt1.usca.ibm.com [9.72.133.177] (may be forged)) by d01av02.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l3I08mtP028992 for ; Tue, 17 Apr 2007 20:08:49 -0400 Message-ID: <46256178.5070003@gmail.com> Date: Tue, 17 Apr 2007 17:08:24 -0700 From: Stanley Bradbury User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Derby Discussion Subject: Re: Drop Table References: <10042954.post@talk.nabble.com> <46252F13.4050304@sbcglobal.net> In-Reply-To: <46252F13.4050304@sbcglobal.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Mike Matrigali wrote: > > > tbrazao wrote: >> Hi, >> >> i'm a new user of derby. >> >> My question is about the ideia of sql : "drop table if exists ...". >> >> I read some explanations in this forum, but i didn´t find answers to >> work in >> sql line commander. >> >> I know that derby doens't support this job, but i want to ensure that >> if an >> table exists it is dropped. So i think we can use something like... >> >> select count(*) from SYS.SYSTABLES where TABLENAME = tableName, >> >> where tableName could be an arg for an procedure, >> but i don´t know how to relate this with an drop call. It was simple >> if we >> have one "if" clause. >> The problem is that i need to do this without java sintax, i know >> that seems >> strange, but life it's strange and nobody cares about it... >> >> If anyone could help, Thanks! > > Why not just drop the table and let derby return an error if it did > not exist? > >> >> And sorry my English! > > You will need to use the Derby API (Java) to perform conditional processing like you describe. The java code can be hidden from the end-users and invoked using IJ by storing it in the database and defining it as a procedure. The procedure would take the table name, drop the table - it would catch and discard the exception thrown if the table does not exist. Example Java code that does something similar to this (checks for existance based on a select statement) can be found in the 10.2 Derby distribution in the method 'wwdChk4Table' defined in 'WwdUtils.java' in the folder: \demo\programs\workingwithderby. HTH