Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 58501 invoked from network); 26 Jun 2008 12:46:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 12:46:27 -0000 Received: (qmail 92384 invoked by uid 500); 26 Jun 2008 12:46:27 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 92362 invoked by uid 500); 26 Jun 2008 12:46:27 -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 92351 invoked by uid 99); 26 Jun 2008 12:46:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 05:46:27 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.43.133] (HELO sca-es-mail-2.sun.com) (192.18.43.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 12:45:36 +0000 Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m5QCjtMD008003 for ; Thu, 26 Jun 2008 05:45:55 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K3200L01M3GCU00@fe-sfbay-10.sun.com> (original mail from Richard.Hillegas@Sun.COM) for derby-user@db.apache.org; Thu, 26 Jun 2008 05:45:55 -0700 (PDT) Received: from richard-hillegas-computer.local ([129.150.16.185]) by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K32001ORM4IYD70@fe-sfbay-10.sun.com> for derby-user@db.apache.org; Thu, 26 Jun 2008 05:45:55 -0700 (PDT) Date: Thu, 26 Jun 2008 05:45:55 -0700 From: Rick Hillegas Subject: Re: Portability issue for 'Like-clause' on non-string types ? In-reply-to: <7b813ada0806252142kb182f89i7134aaa98e974b47@mail.gmail.com> Sender: Richard.Hillegas@Sun.COM To: Derby Discussion Message-id: <48638F83.2050305@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <7b813ada0806252142kb182f89i7134aaa98e974b47@mail.gmail.com> User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) X-Virus-Checked: Checked by ClamAV on apache.org Hi Albert, As Dyre and Donald point out, the LIKE operator can only be applied to strings. You can write your own casting function to turn your integers into strings (or to extract other information which you may be encoding in integers). Something like the following should work: select * from t where intToString( intCol ) like '34%' Note that this kind of query fragment won't be optimizable. That is, the optimizer won't be able to take advantage of useful indexes which you've put on intCol. Hope this helps, -Rick Albert Kam wrote: > Hello again Apache Derby, > > I'm currently porting my little webapp from using mysql to apache derby. > One of the issue i'm having right now is the like clause being used > for non-string types. > I tried the ij, issuing simple sql statement like : > > ij> select sc.id from sms_command sc where sc.id > like '%'; > ERROR 42884: No authorized routine named 'LIKE' of type 'FUNCTION' > having compatible arguments was found. > > But it works fine for the string type : > ij> select sc.id , sc.dbpool_name from sms_command sc > where sc.dbpool_name like 'd%'; > ID |DBPOOL_NAME > --------------------------- > 6 |demo > 14 |demo > 21 |demo > 23 |test > > I tried describe the table, and here's the output : > ij> describe sms_command; > COLUMN_NAME > |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL& > ------------------------------------------------------------------------------ > ID |INTEGER |0 |10 |10 > |NULL |NULL |NO > DBPOOL_NAME |VARCHAR |NULL|NULL|15 |NULL |30 |NO > .... > > I'm quite sure that there's no point in this case to use like-clause > for an integer typed column, but there are several cases that the like > clause can be useful for integer typed column, like when trying to > find out an records that contains such and such part of a number. > > When using mysql, using like-clause on non-string types works in my > proggie prior to porting it to derby. > > Anyway, is there a configuration that can be use to be 'friendly' for > using like-clause on non-string types ? Or perhaps anything else that > i'm missing out from the docs ? :) > > Regards, > Albert Kam > > -- > Do not pursue the past. Do not lose yourself in the future. > The past no longer is. The future has not yet come. > Looking deeply at life as it is in the very here and now, > the practitioner dwells in stability and freedom. > (Thich Nhat Hanh)