今天,实施人员给我反应了一个情况,SELECT DISTINCT CAST(WF_ID AS VARCHAR(20)) WF_ID, 这样的语句会提示ORA-00910: specified length too long for its datatype
通过查找资料发现,可能是CAST在EJB中,在使用上可能有一些bug,具体说明如下:
[@more@]The EJB application using container-managed persistence beans might fail to run with the sql syntax
Symptom:
The EJB application using container-managed persistence beans might fail to run with the sql syntax. This is an Oracle syntax error dealing with an SQL CAST operation. You can see the following exception in the system:
log java.sql.SQLException: ORA-00910:specified length too long for its datatype
Problem:
The problem is a bug in the EJBDeploy program.
Description:
An incorrect CAST operator is generated into SQL for EJB entity beans. This happens when there are multiple EJB-RDB mappings in the EJB or JAR file and one of the mappings is for DB2 and another of the mappings is for another database such as Oracle. When there are multiple mappings, the EJBDeploy tool incorrectly assumes that all mappings are for DB2 and generates incorrect sql for the Oracle case.
Response:
You can work around the problem by removing the unused mappings for the EJB or JAR file.
http://publib.boulder.ibm.com/infocenter/wasinfo/v5r0/index.jsp?topic=/com.ibm.websphere.zseries.doc/info/zseries/relnotes/relnotes_zos.html
所以,我发觉如果不是必须最好不要用,很多可以用类似的语句实现,例如,以上的语句,就可以TO_CHAR来实现。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/60217/viewspace-923109/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/60217/viewspace-923109/