Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 46156 invoked from network); 25 Aug 2010 07:30:40 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Aug 2010 07:30:40 -0000 Received: (qmail 94936 invoked by uid 500); 25 Aug 2010 07:30:40 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 94883 invoked by uid 500); 25 Aug 2010 07:30:38 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 94875 invoked by uid 99); 25 Aug 2010 07:30:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Aug 2010 07:30:38 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of niparasc@gmail.com designates 74.125.82.47 as permitted sender) Received: from [74.125.82.47] (HELO mail-ww0-f47.google.com) (74.125.82.47) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Aug 2010 07:30:32 +0000 Received: by wwb39 with SMTP id 39so522736wwb.28 for ; Wed, 25 Aug 2010 00:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=xKlXPeVu57PJDLqeaA2YwItdCpY7QrYg/RpwzGHl0qY=; b=pPx3qXl5dllF4/vVqlEkuXWheTeQOhyw38fTIBUMwHUSnai5j0uu/etDvCE5llaSX8 CSn9zp9xg2adjQJ+vTDjLACC+lkCDQ2oSv8TN0Uc1q1to82hqIQ4X4fvzX92/Z2KByrW f3xZX/lpPQgGpK++WuAsbukBE1rSYzuuVFsrk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=Jqzd/SwF3eRbL4CWyJtBk0WaIlBB1EWADmsvMpbPR4sETTzGO/mq9IHeHNgXnZYW4f Rw0qWG8IAWswCVAozzG8m8je0q59o4zgP2hzb8mXfr2/gyIYZcA5QSC1/Gdgrwrzkpx/ 5HZ153/rugdoJEKw04M2KTv+sP+SqxxQl3zrg= Received: by 10.227.136.69 with SMTP id q5mr6955206wbt.202.1282721410741; Wed, 25 Aug 2010 00:30:10 -0700 (PDT) Received: from [127.0.0.1] (79.103.244.99.dsl.dyn.forthnet.gr [79.103.244.99]) by mx.google.com with ESMTPS id w31sm891783wbd.3.2010.08.25.00.30.08 (version=SSLv3 cipher=RC4-MD5); Wed, 25 Aug 2010 00:30:09 -0700 (PDT) Message-ID: <4C74C67D.4050706@gmail.com> Date: Wed, 25 Aug 2010 10:30:05 +0300 From: Nikos Paraschou User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: user@cayenne.apache.org Subject: Re: Antwort: INSERT with raw_sql_query returns error References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Thank you Patrick. I thought that if I change the query by removing the #bind from the column names, like this: insert into $schema.$table ($columns) values(#bind($values)) there would be more chances for it to work, but still it doesn't. The problem this time is that when the variable $columns is replaced by the ArrayList columnNames, these two symbols ("[" and "]") are also added to the query causing the error. It becomes like this: insert into mySchema.myTable ([column1, column2, ..., columnn]) values (?, ?, ..., ?) Any idea how I could remove these two symbols ("[" and "]")? Thank you, Nikos On 25/8/2010 7:46 πμ, patrick.mayweg@gi-de.com wrote: > Hi Nikos, > the #bind variables are replaced by PreparedStatement parameters and DB2 > does not allow parameter for column names. > Regards, > Patrick > > > > > Nikos Paraschou > 24.08.2010 23:00 > Bitte antworten an > user@cayenne.apache.org > > > An > user@cayenne.apache.org > Kopie > > Thema > INSERT with raw_sql_query returns error > > > > > > > Hello, > > I have created the following raw sql query inside Cayenne Modeler: > > insert into $schema.$table (#bind($columns)) values(#bind($values)) > > To run it from a java application I use this code: > > String[] keys = new String[] {"schema", "table", "columns", "values"}; > Object[] values = new Object[] {schema, table, columnNames, columnValues}; > NamedQuery query = new NamedQuery("myQuary", keys, values); > context.performQuery(query); > > columnNames and columnValues are both ArrayLists. The binding of the > values to their keys seems to work fine (according to the log messages > when the query is run). Unfortunately, I keep getting a > CayenneRuntimeException caused by: > > com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-727, > SQLSTATE=56098, SQLERRMC=2;-104;42601;(?,?,?,?,?,?,?,?,?,?,?,?,?) > values|AL_STATS_WITH_ID_WCT|<, DRIVER=3.57.82 > > Am I doing something wrong? I am using Cayenne version 3. > > Thank you, > Nikos > >