
__IF_EXISTS__
SELECT 1 FROM CI_INSTALL_PROD WHERE OWNER_FLG = 'CL'
/
__THEN__

insert into CI_MD_TBL_ADDTL (TBL_NAME, TBL_GEN_STATUS_FLG, OWNER_FLG, VERSION)
select TBL_NAME, (case when owner_flg = 'CM' then 'P' else ' ' end), OWNER_FLG, 1 FROM CI_MD_TBL A WHERE NOT EXISTS (SELECT 'X' FROM CI_MD_TBL_ADDTL B WHERE B.TBL_NAME = A.TBL_NAME)
/

__ELSE__

insert into CI_MD_TBL_ADDTL (TBL_NAME, TBL_GEN_STATUS_FLG, OWNER_FLG, VERSION)
select TBL_NAME, ' ', OWNER_FLG, 1 FROM CI_MD_TBL A WHERE NOT EXISTS (SELECT 'X' FROM CI_MD_TBL_ADDTL B WHERE B.TBL_NAME = A.TBL_NAME)
/

__ENDIF__