db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject java.lang.ClassCastException in case statement: Is it a bug
Date Tue, 28 Aug 2007 23:21:02 GMT
I was wondering if the cast exception returning null from a case 
statement is expected or a bug.  If I cast the NULL to DATE it works ok.


ij> create table t (d date, vc varchar(30));
0 rows inserted/updated/deleted
ij> insert into t values(CURRENT_DATE, 'hello');
1 row inserted/updated/deleted
ij> SELECT d from t where d = (SELECT CASE WHEN 1 = 1 THEN CURRENT_DATE 
ELSE NULL END from t);
D
----------
2007-08-28

1 row selected
ij> SELECT d from t where d = (SELECT CASE WHEN 1 = 0 THEN CURRENT_DATE  
ELSE NULL END from t);
D
----------
ERROR 38000: The exception 'java.lang.ClassCastException: 
org.apache.derby.iapi.types.SQLChar incompatible with org.apac
he.derby.iapi.types.DateTimeDataValue' was thrown while evaluating an 
expression.
java.sql.SQLException: The exception 'java.lang.ClassCastException: 
org.apache.derby.iapi.types.SQLChar incompatible wit
h org.apache.derby.iapi.types.DateTimeDataValue' was thrown while 
evaluating an expression.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at 
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88)
        at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:224)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:1572)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(EmbedResultSet.java:4323)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:464)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:368)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:382)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:338)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:241)
        at 
org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:229)
        at 
org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:449)
        at 
org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:523)
        at 
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:364)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:262)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:215)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56)
        at org.apache.derby.tools.ij.main(ij.java:71)
Caused by: java.sql.SQLException: Java exception: 
'org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derb
y.iapi.types.DateTimeDataValue: java.lang.ClassCastException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at 
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:245)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
        ... 19 more
Caused by: java.lang.ClassCastException: 
org.apache.derby.iapi.types.SQLChar incompatible with 
org.apache.derby.iapi.typ
es.DateTimeDataValue
        at 
org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.g0(Unknown 
Source)
        at 
org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.e1(Unknown 
Source)
        at 
org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:141)
        at 
org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:267)
        at 
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:468)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:424)
        ... 13 more
ERROR XJ001: Java exception: 'org.apache.derby.iapi.types.SQLChar 
incompatible with org.apache.derby.iapi.types.DateTime
DataValue: java.lang.ClassCastException'.
java.sql.SQLException: Java exception: 
'org.apache.derby.iapi.types.SQLChar incompatible with 
org.apache.derby.iapi.type
s.DateTimeDataValue: java.lang.ClassCastException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at 
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:245)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:1572)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(EmbedResultSet.java:4323)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:464)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:368)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:382)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:338)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:241)
        at 
org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:229)
        at 
org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:449)
        at 
org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:523)
        at 
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:364)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:262)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:215)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56)
        at org.apache.derby.tools.ij.main(ij.java:71)
Caused by: java.lang.ClassCastException: 
org.apache.derby.iapi.types.SQLChar incompatible with 
org.apache.derby.iapi.typ
es.DateTimeDataValue
        at 
org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.g0(Unknown 
Source)
        at 
org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.e1(Unknown 
Source)
        at 
org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:141)
        at 
org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:267)
        at 
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:468)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:424)
        ... 13 more


Mime
View raw message