Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 58065 invoked from network); 29 Sep 2006 15:44:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Sep 2006 15:44:48 -0000 Received: (qmail 64782 invoked by uid 500); 29 Sep 2006 15:44:46 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 64734 invoked by uid 500); 29 Sep 2006 15:44:46 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 64706 invoked by uid 99); 29 Sep 2006 15:44:46 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Sep 2006 08:44:46 -0700 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= Received: from [209.237.227.198] ([209.237.227.198:37341] helo=brutus.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id DE/37-13110-D6F3D154 for ; Fri, 29 Sep 2006 08:44:45 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A681C714212 for ; Fri, 29 Sep 2006 15:40:52 +0000 (GMT) Message-ID: <30765250.1159544452679.JavaMail.jira@brutus> Date: Fri, 29 Sep 2006 08:40:52 -0700 (PDT) From: "A B (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-1904) COALESCE with NULL parameter problem In-Reply-To: <17009543.1159536415004.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-1904?page=3Dcomments#actio= n_12438737 ]=20 =20 A B commented on DERBY-1904: ---------------------------- Do you have a full stack trace for the NullPointerException error that you = see with ij? Ex. can you run the above query and then attach the derby.log= file to this issue? I did the simple CREATE TABLE statement and then tried to execute the query= , but a) the query references a column ITM_NAME that isn't in your table, a= nd b) when I removed the ITM_NAME from the select list, the queries run wit= hout error. So I'm wondering if the problem is specific to your table sche= ma and/or data. Can you use the dblook tool to generate the DDL for your I= TEMS table and then post that, as well? That is, run java org.apache.derby.tools.dblook -d jdbc:derby: -t items and then include the output here. Having a full stack trace and the full DDL for the table in question might = make it easier for interested people to investigate this problem more...Tha= nks! > COALESCE with NULL parameter problem > ------------------------------------ > > Key: DERBY-1904 > URL: http://issues.apache.org/jira/browse/DERBY-1904 > Project: Derby > Issue Type: Bug > Components: JDBC, SQL > Affects Versions: 10.1.3.1 > Environment: Windows 2000 SP4 > JSTL 1.0.6 on J2EE 1.3 > Tomcat 5.0.28 using a SUN JVM 1.4.2_03 > Reporter: C=C3=A9dric G=C3=A9rard > Priority: Blocker > > Hi, > My initial objective was to execute this query with the JSTL sql tag li= brary : > =20 > SELECT ID_ITM, ITM_NAME, ITM_CODE > FROM ITEMS > WHERE ITM_CODE =3D COALESCE(?,ITM_CODE) > =20 > ITM_CODE is a NUMERIC column, here's the DDL script of the ITEMS table : > CREATE TABLE ITEMS ( =20 > ID_ITM BIGINT NOT NULL GENERATED ALWAYS AS IDE= NTITY,=20 > ITM_CODE NUMERIC (22) NOT NULL > ); > When ITM_CODE is not set in my application, JSTL bind the parameter as nu= ll. When ITM_CODE is set, it works. > =20 > I got this message error :=20 > : Invalid data conversion: Parameter object type is invalid for request= ed conversion. (Apache > Derby release 10.1.3.1 client driver) > =3D> We try to use CAST(? AS NUMERIC) in place of ?. We obtain the same e= rror when NULL is passed. > : The exception 'java.lang.ArrayIndexOutOfBoundsException: -1' was thro= wn while evaluating > an expression. SQLSTATE: XJ001: Java exception: '-1: java.lang.ArrayInde= xOutOfBoundsException'. > (Apache Derby snapshot-10.2.0.4 client driver) > With ij, we have the same problem (but not the same message) > ij> SELECT ID_ITM, ITM_NAME, ITM_CODE > FROM ITEMS > WHERE ITM_CODE =3D COALESCE(NULL,ITM_CODE ); > ERROR 42X01: Syntax error: Encountered "NULL" at line 3, column 31. > ij> SELECT ID_ITM, ITM_NAME, ITM_CODE > FROM ITEMS > WHERE ITM_CODE =3D COALESCE(NULLIF(1,1),ITM_CODE ); > ID_ITM |ITM_NAME |I= TM_CODE > -------------------------------------------------------------------------= ----------------------- > ERROR 38000: The exception 'java.lang.NullPointerException' was thrown wh= ile evaluating an expression. SQLSTATE: XJ001: Java exception: ': java.lang= .NullPointerException'. > ij> SELECT ID_ITM, ITM_NAME, ITM_CODE > FROM ITEMS > WHERE ITM_CODE =3D COALESCE(CAST(NULLIF(1,1) AS BIGINT), ITM_CODE); > ID_ITM |ITM_NAME |I= TM_CODE > -------------------------------------------------------------------------= ----------------------- > ERROR 38000: The exception 'java.lang.NullPointerException' was thrown wh= ile evaluating an expression. SQLSTATE: XJ001: Java exception: ': java.lang= .NullPointerException'. > We have the same errors using 10.2.0.4 snapshot. > The coalesce function should accept NULL parameter. > Of course, My sample is very simple and I have n search criteria; so I do= n't want to create 2^n SQL queries to deal with null or not null criterion. > I try to replace the coalesce function with a CASE statement but I encoun= tered the same problems... > So I don't actually have any workaround. > Regards, > C=C3=A9dric --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira