__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
 WHERE SCRIPT_FILE_NAME = 'FW410_APDATA31.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__

__EXIT__

__ENDIF__


__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
 WHERE UPPER(SCRIPT_FILE_NAME) = '12874623_RS8.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__

__EXIT__

__ENDIF__



__IF_EXISTS__
SELECT 1
  FROM CI_INSTALL_PROD
 WHERE INSTALL_OPT_ID = '11111'
   AND OWNER_FLG = 'F1'
/
__ELSE__

__EXIT__

__ENDIF__


update  CI_MD_TBL_FLD tf
  set tf.nullable_sw = 'N'
   where tf.nullable_sw = 'Y'
     and upper(trim(tf.tbl_name)) not like 'ZZ%'
     and tf.fld_name in (select f.fld_name
   from CI_MD_FLD f
   where upper(f.data_type_flg) not in ('DATE', 'DTTM', 'TM', 'CLOB')
     and upper(f.fld_name) not like 'ZZ%'
   )
   and exists (select 'X' From CI_MD_TBL A
    where upper(trim(a.tbl_name)) = upper(trim(tf.tbl_name))
      and A.TBL_TYPE_FLG = 'TBL')
/


update  CI_MD_TBL_FLD tf
     set  tf.nullable_sw = 'N'
   where tf.nullable_sw = 'Y'
     and upper(tf.tbl_name) not like 'ZZ%'
     and tf.fld_name in (select f.fld_name
   from CI_MD_FLD f
   where upper(f.data_type_flg) in ('DATE', 'DTTM', 'TM', 'CLOB')
     And Upper(F.Fld_Name) Not Like 'ZZ%'
   )
   And exists (Select 'X' From User_Constraints A, User_Cons_Columns B
 Where A.Table_Name = Upper(trim(tf.Tbl_Name))
 And B.Column_Name = Upper(trim(tf.Fld_Name))
 and A.Constraint_Type = 'P'
 And A.Constraint_Name = B.Constraint_Name
 And A.Table_Name = B.Table_Name
 )
 and exists (Select 'X' From CI_MD_TBL C
  where upper(trim(C.tbl_name)) = upper(trim(tf.tbl_name))
   and C.TBL_TYPE_FLG = 'TBL')
/



update  CI_MD_TBL_FLD tf
      set tf.nullable_sw = 'N'
    where tf.nullable_sw = 'Y'
     And Upper(Tf.Tbl_Name) Not Like 'ZZ%'
     and exists (Select 'X' From User_tab_columns A, CI_MD_TBL B
 Where A.Table_Name = Upper(trim(tf.Tbl_Name))
 And A.Column_Name = Upper(Trim(Tf.Fld_Name))
 And A.Table_Name = Upper(Trim(B.Tbl_Name))
 And B.TBL_TYPE_FLG = 'TBL'
 And A.Nullable ='N'
 )
/


