DB2查询未知列名ERRORCODE = -4460,SQLSTATE = null

时间:2013-04-08 16:58:53

标签: sql db2

一位同事一直困扰着我们所有人,因为我们无法理解的原因导致我们失败。我可以确认数据库中确实存在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。 ERRORCODE = -4460,   SQLSTATE =空

3 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:0)

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

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

从ID = 1的表中选择MY_NAME

例如,将空白与列名连接起来:

选择“ COLUMN_NAME” || ”作为MY_NAME,来自TABLE,其中ID = 1

答案 2 :(得分:0)

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

我收到此错误,已从以下位置更改列:

const fields = new Formidable.IncomingForm({ multiples: true, keepExtensions: false, }); fields.parse(req, (err, fields, files) => { let filename = files.file.map((a) => uuidv4() + a.name); }

... AS PREVIOUS_MONTH_REDEEMED_RESULTS ...

而且效果很好!