sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

PreparedStatement failed #394

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
PreparedStatement failed when it try to parse the following query:

UPDATE TABLE_NAME SET CODE = CASE WHEN ?='' THEN NULL ELSE ? END;

nested org.h2.jdbc.JdbcSQLException: Unknown data type: "NULL, ?"; SQL 
statement:
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.value.Value.getHigherOrder(Value.java:317)
    at org.h2.expression.Function.optimize(Function.java:1789)
    at org.h2.command.dml.Update.prepare(Update.java:184)
    at org.h2.command.Parser.prepareCommand(Parser.java:218)
    at org.h2.engine.Session.prepareLocal(Session.java:415)
    at org.h2.engine.Session.prepareCommand(Session.java:364)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1111)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:266)

Original issue reported on code.google.com by White...@gmail.com on 23 Apr 2012 at 12:35

GoogleCodeExporter commented 8 years ago
Hi,

Please use StackOverflow or the Google Group for questions.

In this case the database doesn't know the data type. Try using CAST(... AS 
VARCHAR) or similar.

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 25 Apr 2012 at 6:56