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.may...@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<nipar...@gmail.com>
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



Reply via email to