我遇到此错误ORA-00972:执行以下脚本时标识符过长。
SELECT distinct
" AMACADRAD_1.APP_PRTFL_ID ""Portfolio ID"""
", AMCIDRCD_1.CI_LONG_DN ""Application Description"""
", AMCIDRCD_1.CI_NM ""Application Name"""
"
答案 0 :(得分:4)
在SQL中,双引号用于定义标识符。它们是可选的,但如果包含在内,它们将更改名称中有效字符的性质。例如_EMP
不是有效的表名,而"_EMP"
是有效的表名。
如果您考虑查询,则所有内容均以双引号引起来,这意味着所有内容均视为标识符。此字符串的长度为44个字符(包括空格)...
" AMACADRAD_1.APP_PRTFL_ID "
...这就是为什么Oracle发出ORA-00972的原因。
此外,您不太可能拥有诸如...之类的列。
", to_char(AMCIDRCD_1.SRC_SYS_UPD_DT,'DD-MON-YYYY HH24:MI:SS') "
...因此您的查询也将在ORA-00904上失败。
幸运的是,解决方案非常简单:只需删除双引号即可。好吧,如果您确实需要带有空格的列别名,例如"Application Description"
,请保留它们。但删除所有其他。
因此,这意味着您的查询应如下所示:
SELECT distinct
AMACADRAD_1.APP_PRTFL_ID "Portfolio ID"
, AMCIDRCD_1.CI_LONG_DN "Application Description"
, AMCIDRCD_1.CI_NM "Application Name"
, decode(( AMCSDRHMLCD_1.MSTR_L_COL_ID ),'ML_CI_STAT_KY',( AMCSDRHMLCD_1.DSPLY_DN ),'does not apply',( AMCSDRHMLCD_1.DSPLY_DN ),'not found',( AMCSDRHMLCD_1.DSPLY_DN ),'not avail',( AMCSDRHMLCD_1.DSPLY_DN )) "Status Description"
, AMIAOAODRAGOHD_2.ASGN_GRP_ORG_LVL_2_NM "Biz Asset Owner Level 2 Name"
, AMCIDRCD_1.BUS_OWN_EMAIL_NM_LIST_TX "Bus Owner Email"
, AMCIDRCD_1.IT_ASSET_OWN_CNTCT_TX "IT Owner Email Address"
, decode(( AMCSDRHMLCD_3.MSTR_L_COL_ID ),'ML_DATA_CLS_KY',( AMCSDRHMLCD_3.DSPLY_DN ),'does not apply',( AMCSDRHMLCD_3.DSPLY_DN ),'not found',( AMCSDRHMLCD_3.DSPLY_DN ),'not avail',( AMCSDRHMLCD_3.DSPLY_DN )) "Data Class"
, decode(( AASDDRAASD_1.MSTR_L_COL_ID ),'ML_CI_CRTCLTY_KY',( AASDDRAASD_1.DSPLY_DN ),'does not apply',( AASDDRAASD_1.DSPLY_DN ),'not found',( AASDDRAASD_1.DSPLY_DN ),'not avail',( AASDDRAASD_1.DSPLY_DN )) "Business Criticality"
, to_char(AMCIDRCD_1.SRC_SYS_UPD_DT,'DD-MON-YYYY HH24:MI:SS') "CI Updated"
FROM ITR23.APP_CI_DTL_F adf
inner join ITR23.APP_D AMACADRAD_1
on AMACADRAD_1.app_ky = adf.app_ky
那些DECODE()语句看起来不对,我无法猜测您要如何处理它们。