Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A249F10D16 for ; Tue, 30 Apr 2013 16:28:45 +0000 (UTC) Received: (qmail 45736 invoked by uid 500); 30 Apr 2013 16:28:45 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 45714 invoked by uid 500); 30 Apr 2013 16:28:45 -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 45706 invoked by uid 99); 30 Apr 2013 16:28:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 16:28:45 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rick.hillegas@oracle.com designates 156.151.31.81 as permitted sender) Received: from [156.151.31.81] (HELO userp1040.oracle.com) (156.151.31.81) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 16:28:38 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3UGSGuq021463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Apr 2013 16:28:16 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3UGSFos000968 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 30 Apr 2013 16:28:16 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3UGSFs0022945 for ; Tue, 30 Apr 2013 16:28:15 GMT Received: from dhcp-whq-twvpn-1-vpnpool-10-159-140-132.vpn.oracle.com (/10.159.140.132) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Apr 2013 09:28:15 -0700 Message-ID: <517FF11C.3040306@oracle.com> Date: Tue, 30 Apr 2013 09:28:12 -0700 From: Rick Hillegas User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.7; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: derby-user@db.apache.org Subject: Re: Call statement with an SQL request as an input parameter References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-Virus-Checked: Checked by ClamAV on apache.org On 4/30/13 8:51 AM, Guillaume CHAUVET wrote: > > Hi, > > Below, please find a small SQL script intended to inject a value > selected from an SQL request as a input call statement parameter : > > *SELECT center FROM APP.SETTINGS WHERE ID = 1 * > > >Return a varchar(128) string, for example: �test� > > Now, I try to use this value as a input parameter in a call statement : > > *CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('center', (SELECT center > FROM APP.SETTINGS WHERE ID = 1)); * > > />Error code -1, SQL state XJ001: DERBY SQL error: SQLCODE: -1, > SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException XJ001.U / > > />Line 1, column 1 / > > />[This SQL request reset the JDBC connection] / > > According to you, is it the expected behaviour or a bug ? > > -- > > Regards, > > Guillaume > Hi Guillaume, Both arguments to that system procedure should be strings. In your example, the second argument is not enclosed in single quotes, so the parser does not interpret it as a string. That's why you get the error you are seeing. But it sounds as though you don't want to bind that SELECT string as the value of the "center" key. Instead, what you want to bind to "center" is the result of running that SELECT. You will need to run 2 statements: 1) Run the SELECT and retrieve its string result. 2) In a separate statement, bind that result to the "center" key by calling the system procedure. Hope this helps, -Rick