2

一位同事让我们所有人都感到困惑,因为我们无法预测的原因导致查询失败。我可以确认ENOTE.EN_FILTER_VALUE_L.FILTER_VALUE_DECODE数据库中确实存在。至少有三个人盯着它试图找出拼写错误。

查询:

SELECT sub.ID, sub.USER_ID, sub.EN_TYPE_CODE, 
typ.EN_TYPE_DESC, typ.APPL_CD, filterval.FILTER_VALUE_DECODE AGENCY_TYPE, 
sub.EN_TYPE_CODE CONCAT ' | ' CONCAT typ.EN_TYPE_DESC ENOTE_STRING, 
org1.ORG_LVL1_CD, org1.ORG_LVL1_DC,
org2.ORG_LVL2_CD, org2.ORG_LVL2_DC,
org3.ORG_LVL3_CD, org3.ORG_LVL3_DC, 
org4.ORG_LVL4_CD, org4.ORG_LVL4_DC 
FROM ENOTE.EN_SUBSCRIPTION_T sub 
LEFT JOIN ENOTE.EN_TYPE_L typ ON sub.EN_TYPE_CODE = typ.EN_TYPE_CODE 
LEFT JOIN ENOTE.EN_FILTER_OFFICE_T filteroffice ON sub.ID = filteroffice.SUBSCRIPTION_ID
LEFT JOIN UMC.ORG_LVL4_L org4 ON org4.ORG_LVL4_CD = filteroffice.ORG_LVL4_CODE
      AND org4.ORG_LVL3_CD = filteroffice.ORG_LVL3_CODE
      AND org4.ORG_LVL2_CD = filteroffice.ORG_LVL2_CODE 
      AND org4.ORG_LVL1_CD = filteroffice.ORG_LVL1_CODE 
      AND org4.STRUCTURE_CD = filteroffice.STRUCTURE_CODE 
LEFT JOIN UMC.ORG_LVL3_L org3 ON org3.ORG_LVL3_CD = filteroffice.ORG_LVL3_CODE 
      AND org3.ORG_LVL2_CD = filteroffice.ORG_LVL2_CODE 
      AND org3.ORG_LVL1_CD = filteroffice.ORG_LVL1_CODE 
      AND org3.STRUCTURE_CD = filteroffice.STRUCTURE_CODE 
LEFT JOIN UMC.ORG_LVL2_L org2 ON org2.ORG_LVL2_CD = filteroffice.ORG_LVL2_CODE 
      AND org2.ORG_LVL1_CD = filteroffice.ORG_LVL1_CODE
      AND org2.STRUCTURE_CD = filteroffice.STRUCTURE_CODE 
LEFT JOIN UMC.ORG_LVL1_L org1 ON org1.ORG_LVL1_CD = filteroffice.ORG_LVL1_CODE 
      AND org1.STRUCTURE_CD = filteroffice.STRUCTURE_CODE
LEFT JOIN ENOTE.EN_FILTER_VALUE_L filterval ON 
   (filteroffice.AGENCY_TYPE_CODE = filterval.FILTER_VALUE AND filterval.FILTER_NAME   = 'Agency Type')

例外:

com.ibm.db2.jcc.a.SqlException:[jcc][10150][10300][4.3.111] 无效参数:未知列名 FILTER_VALUE_DECODE。错误代码=-4460,SQLSTATE=null

4

3 回答 3

3

我在这里重新问了这个问题db2jcc4.jar Invalid parameter: Unknown column name并得到了答案。

Hibernate 3.x 和 DB2 9.5 及更高版本中的 JCC 驱动程序的组合存在规范级别不匹配。升级到 Hibernate 4.x 将解决问题,但如果您不能在短期内这样做,设置自定义数据源属性useJDBC4ColumnNameAndLabelSemantics=2可以解决问题。

于 2013-04-15T12:39:59.933 回答
0

较新的 DB2 JDBC 驱动程序在使用“AS”子句返回列名时表现出不同的行为。

修改查询以在列名中使用表达式:

从 ID=1 的 TABLE 中选择为 MY_NAME

例如,将空格与列名连接:

选择 COLUMN_NAME || '' as MY_NAME from TABLE where ID=1

于 2020-01-09T06:10:38.013 回答
0

这可能是别名长度的问题吗?

我收到此错误,将列更改为:

... AS PREVIOUS_MONTH_REDEEMED_RESULTS ...

... AS pmrr ...

而且效果很好!

于 2021-05-12T18:50:55.283 回答