Error Using an Alias Name - Is CM a reserved keyword in TeraData

Database
Enthusiast

Error Using an Alias Name - Is CM a reserved keyword in TeraData

Hi,
When i run the following query , i get an error as 3706:Syntax Error: something expected between ',' and the 'cm' keyword

SELECT

TBL.BENEFIT_PKG,
TBL.SOURCEID,
TBL.DESCRIPTION,
TBL.PD_CLASS_EFF_DT
CM.BENEFIT_PKG CM_PKG_CD
FROM
(
SELECT

F.BENEFIT_PKG BENEFIT_PKG,
F.SOURCEID SOURCEID,
F.DESCRIPTION DESCRIPTION,
F.ODS_TRANS_DATE ODS_TRANS_DATE,
F.ROW_SEQ_NUM ROW_SEQ_NUM,

AL.APPL_PLAN_DSGN_CD APPL_PLAN_DSGN_CD,
AL.EDW_PLAN_DSGN_K EDW_PLAN_DSGN_K,
AL.PLAN_DSGN_CD PLAN_DSGN_CD,

COALESCE(PD.PD_CLASS_BNFT_LEVEL_ID,'0') PD_CLASS_BNFT_LEVEL_ID,
COALESCE(PD.PD_CLASS_TIER_TYP_ID,'0') PD_CLASS_TIER_TYP_ID,
PD.PLAN_DSGN_DSC PLAN_DSGN_DSC,
CAST(PD.SLS_BEG_DT AS CHAR(10)) SLS_BEG_DT,
CAST(PD.SLS_END_DT AS CHAR(10)) SLS_END_DT,
CAST(PD.PD_CLASS_EFF_DT AS CHAR(10)) PD_CLASS_EFF_DT

FROM UA_EDW_DEVL.BENEFIT_PKG_M_FS_IN F

LEFT JOIN UA_EDW_DEVL.PD_PLAN_DSGN_AL AL
ON F.BENEFIT_PKG = AL.APPL_PLAN_DSGN_CD
AND AL.SRC_CD = 'CM'

LEFT JOIN UA_EDW_DEVL.PD_PLAN_DSGN PD
ON AL.EDW_PLAN_DSGN_K = PD.EDW_PLAN_DSGN_K
AND PD.EDW_EFF_END_DT = '9999-12-31'
) TBL
LEFT JOIN EDWSRCVIEW.BENEFIT_PKG_M_CM_MR CM

ON TBL.BENEFIT_PKG = CM.BENEFIT_PKG

ORDER BY TBL.BENEFIT_PKG

However when i change the alias name from "CM" to "FS" as

LEFT JOIN EDWSRCVIEW.BENEFIT_PKG_M_CM_MR FS

the query works fine.

What can be the problem?

1 REPLY
Junior Contributor

Re: Error Using an Alias Name - Is CM a reserved keyword in TeraData

Hi Sam,
CM is an abbreviation for CREATE MACRO, so it's a keyword.

You'll find a list of all keywords in:
SQL Reference: Fundamentals
Appendix B: Restricted Words for V2R6.1

Dieter