Question : DB2 Equivalent of IN

This query...

SELECT LOWES.T572_SHP_LCT_GRP.T162_CGY_SHT_NME, LOWES.T556_RP_MP_VBU.T627_FRG_TER_CD, LOWES.T556_RP_MP_VBU.T1085_CAC_MTH_ID, LOWES.T554_RP.T605_RP_TYP_ID, OXD_SWT_1XD_IDC, LOWES.T1085_TRO_CAC_MTH.DES_TXT, LOWES.T750_EFC_HDR_EXC.IFM_PRM_NBR, LOWES.T748_EFC_HDR_PRM.IFM_PRM_NBR, LOWES.T556_RP_MP_VBU.IFM_SRCHFLAG_TXT, LOWES.T556_RP_MP_VBU.IFM_HDFLAGTAB_1TXT, LOWES.T556_RP_MP_VBU.IFM_VRMIN_1_NBR, LOWES.T556_RP_MP_VBU.IFM_VRMAX_1_NBR, LOWES.T556_RP_MP_VBU.IFM_HDFLAGTAB_2TXT, LOWES.T556_RP_MP_VBU.IFM_VRMIN_2_NBR, LOWES.T556_RP_MP_VBU.IFM_VRMAX_2_NBR FROM LOWES.T554_RP INNER JOIN ((LOWES.T556_RP_MP_VBU INNER JOIN (LOWES.T748_EFC_HDR_PRM INNER JOIN (LOWES.T572_SHP_LCT_GRP LEFT JOIN LOWES.T750_EFC_HDR_EXC ON (INT(Replace(LOWES.T572_SHP_LCT_GRP.T162_CGY_SHT_NME,'DC','')) = INT(Replace(LOWES.T750_EFC_HDR_EXC.T162_CGY_SHT_NME,'DC',''))) AND (LOWES.T572_SHP_LCT_GRP.T616_VBU_NBR = LOWES.T750_EFC_HDR_EXC.T616_VBU_NBR) AND (LOWES.T572_SHP_LCT_GRP.T619_MP_NBR = LOWES.T750_EFC_HDR_EXC.T619_MP_NBR) AND (LOWES.T572_SHP_LCT_GRP.
T554_RP_NBR = LOWES.T750_EFC_HDR_EXC.T554_RP_NBR)) ON (LOWES.T748_EFC_HDR_PRM.T616_VBU_NBR = LOWES.T572_SHP_LCT_GRP.T616_VBU_NBR) AND (LOWES.T748_EFC_HDR_PRM.T619_MP_NBR = LOWES.T572_SHP_LCT_GRP.T619_MP_NBR) AND (LOWES.T748_EFC_HDR_PRM.T554_RP_NBR = LOWES.T572_SHP_LCT_GRP.T554_RP_NBR)) ON (LOWES.T556_RP_MP_VBU.T616_VBU_NBR = LOWES.T572_SHP_LCT_GRP.T616_VBU_NBR) AND (LOWES.T556_RP_MP_VBU.T619_MP_NBR = LOWES.T572_SHP_LCT_GRP.T619_MP_NBR) AND LOWES.T556_RP_MP_VBU.T554_RP_NBR = LOWES.T572_SHP_LCT_GRP.T554_RP_NBR) INNER JOIN LOWES.T1085_TRO_CAC_MTH ON LOWES.T556_RP_MP_VBU.T1085_CAC_MTH_ID = LOWES.T1085_TRO_CAC_MTH.T1085_CAC_MTH_ID) ON LOWES.T554_RP.T554_RP_NBR = LOWES.T572_SHP_LCT_GRP.T554_RP_NBR WHERE INT(REPLACE(LOWES.T572_SHP_LCT_GRP.T162_CGY_SHT_NME,'DC','') IN (955,960,961,962,965,966,990,992,1419,1420,1421,1436,1440,1449,964,1438,1439,1446) AND LOWES.T556_RP_MP_VBU.T554_RP_NBR=1 AND LOWES.T556_RP_MP_VBU.T619_MP_NBR=1 AND LOWES.T556_RP_MP_VBU.T616_VBU_NBR=1 AND LOWES.T748_EFC_HDR_PRM.IFM_PRM_TXT='G';

...triggers the error message The use of the reserved word "IN" following "" is not valid. Expected tokens include:

What is the correct DB2 syntax for IN?

Answer : DB2 Equivalent of IN

DB2 does support IN.  However, it would appear from the error that your query is returning an empty string for the "INT(REPLACE(LOWES.T572_SHP_LCT_GRP.T162_CGY_SHT_NME,'DC','')".  (In fact, if you copied the query into your question exactly as it appears, then you are missing a closing ')'.  So that would mean you are trying to check a string against a list of integers, because the INT function is not completing.  Please confirm this.)  You should probably add:
  REPLACE(LOWES.T572_SHP_LCT_GRP.T162_CGY_SHT_NME,'DC','') <> '' AND
ahead of the "INT(...) IN (...)" part of the WHERE clause.  This would make sure no empty strings are not being used with IN.
Random Solutions  
 
programming4us programming4us