__IF_EXISTS__
SELECT 1
FROM F1_INSTALLATION
/
__ELSE__

INSERT INTO F1_INSTALLATION ( INSTALL_OPT_ID, CURRENCY_CD, LANGUAGE_CD, VERSION, CHAR_DFLT_DT,
 ADMIN_MENU_ORD_FLG, ENV_ID, OWNER_FLG,  TIME_ZONE_CD,SEAS_TM_SH_REQ_SW )
 VALUES ('11111', 'USD', 'ENG', 1,  TO_Date( '01/01/1950 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), 
'FUNC', 0, 'CM', 'UTC', 'N') 
/

__ENDIF__


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

UPDATE CI_INSTALL_PROD
 SET UPDATE_DTTM = SYSDATE, VERSION = VERSION + 1, RELEASE_ID = 'V4.5.0.1.1',BUILD_NBR = '000', PRODUCT_NAME = 'Oracle Utilities Application Framework', SORT_SEQ = 98
 WHERE OWNER_FLG = 'F1'
/
__ELSE__

INSERT INTO CI_INSTALL_PROD ( INSTALL_OPT_ID, OWNER_FLG, RELEASE_ID, COMP_STATUS_FLG, UPDATE_DTTM,
VERSION, SORT_SEQ, BUILD_NBR, PATCH_NBR, DISPLAY_SW, PRODUCT_NAME ) VALUES ( 
'11111', 'F1  ', 'V4.5.0.1.1', 'COMP',  SYSDATE , 1, 98, '000', '000', 'N', 'Oracle Utilities Application Framework')
/
__ENDIF__


__IF_EXISTS__

SELECT 1
FROM SC_USER where USER_ID = 'SYSUSER'
/
__ELSE__

INSERT INTO SC_USER ( USER_ID, LANGUAGE_CD, FIRST_NAME, LAST_NAME, TNDR_SOURCE_CD, VERSION,
DISP_PROF_CD, TD_ENTRY_AGE_DAYS1, TD_ENTRY_AGE_DAYS2, ACCESS_GRP_CD, EMAILID, USER_TYPE_FLG,
PORTAL_OVRD_USER, FAV_OVRD_USER, DASHBOARD_WIDTH, HOME_NAV_OPT_CD, DISP_ALL_PREM_SW,
OWNER_FLG,EXT_USER_ID,USER_ENABLE_FLG ) VALUES ( 
'SYSUSER ', 'ENG', 'English', 'System', '        ', 1, 'NORTHAM   ', 50, 100, ' '
, ' ', '    ', '        ', '        ', '300', 'CI0000000574                    '
, 'Y', 'F1  ','SYSUSER','ENBL')
/

__ENDIF__


__IF_EXISTS__

SELECT 1
FROM SC_USER_GROUP WHERE USR_GRP_ID = 'ALL_SERVICES'
/
__ELSE__

INSERT INTO SC_USER_GROUP ( USR_GRP_ID, VERSION, OWNER_FLG ) VALUES ( 
'ALL_SERVICES', 7, 'F1  ')
/
__ENDIF__

__IF_EXISTS__

SELECT 1
FROM SC_USER_GROUP_L WHERE USR_GRP_ID = 'ALL_SERVICES'
/
__ELSE__

INSERT INTO SC_USER_GROUP_L ( USR_GRP_ID, LANGUAGE_CD, DESCR, VERSION,
OWNER_FLG ) VALUES ( 
'ALL_SERVICES        ', 'ENG', 'All Services', 1, 'F1  ')
/ 

__ENDIF__


__IF_EXISTS__

SELECT 1
FROM SC_USR_GRP_USR WHERE USR_GRP_ID = 'ALL_SERVICES' AND USER_ID = 'SYSUSER'
/
__ELSE__

INSERT INTO SC_USR_GRP_USR ( USR_GRP_ID, USER_ID, VERSION, EXPIRATION_DT,
OWNER_FLG ) VALUES ( 
'ALL_SERVICES        ', 'SYSUSER ', 1,  TO_Date( '12/31/2100 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM')
, 'F1  ')
/

__ENDIF__



__IF_EXISTS__
SELECT 1
FROM CI_INSTALL_PROD WHERE OWNER_FLG = 'CM'
/

__THEN__

UPDATE CI_INSTALL_PROD
 SET UPDATE_DTTM = SYSDATE, VERSION = VERSION + 1, SORT_SEQ = 2
 WHERE OWNER_FLG = 'CM'
/

UPDATE CI_INSTALL_PROD
SET PRODUCT_NAME = TRIM(PRODUCT_NAME)
WHERE OWNER_FLG = 'CM'
  AND PRODUCT_NAME <> TRIM(PRODUCT_NAME)
/


__ELSE__

INSERT INTO CI_INSTALL_PROD ( INSTALL_OPT_ID, OWNER_FLG, RELEASE_ID, COMP_STATUS_FLG, UPDATE_DTTM,
VERSION, SORT_SEQ, BUILD_NBR, PATCH_NBR, DISPLAY_SW, PRODUCT_NAME ) VALUES ( 
'11111', 'CM  ', 'V4.5.0.1.1', 'COMP',  SYSDATE , 1, 2, '000', '000', 'N', 'Customer Release') 
/

__ENDIF__

__IF_EXISTS__
SELECT 1
FROM CI_SEQ WHERE SEQ_NAME = 'SCHEDULER-ID'
/
__THEN__
UPDATE CI_SEQ SET OWNER_FLG = 'F1' WHERE SEQ_NAME = 'SCHEDULER-ID'
/
__ELSE__
INSERT INTO CI_SEQ ( SEQ_NAME, SEQ_NBR, VERSION, OWNER_FLG ) VALUES ( 
'SCHEDULER-ID', 1, 1, 'F1  ')
/
__ENDIF__

__IF_EXISTS__
SELECT 1
FROM CI_SEQ WHERE SEQ_NAME = '#CI_NT_UP'
/
__THEN__
UPDATE CI_SEQ SET OWNER_FLG = 'F1' WHERE SEQ_NAME = '#CI_NT_UP'
/

__ELSE__
INSERT INTO CI_SEQ ( SEQ_NAME, SEQ_NBR, VERSION, OWNER_FLG ) SELECT
'#CI_NT_UP           ', nvl2(MAX(NT_UP_ID), MAX(NT_UP_ID) + 1, 1), 1, 'F1  '
FROM CI_NT_UP
/


__ENDIF__


__IF_EXISTS__

SELECT 1
FROM USER_TABLES WHERE TABLE_NAME like 'CI_WFM%'
/

__THEN__

INSERT INTO CI_WFM ( WFM_NAME, VERSION, EXT_SYS_TYP_FLG) SELECT 'F1_DBCONINFO', 1, 'F1DB' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM 
CI_WFM WHERE WFM_NAME = 'F1_DBCONINFO' AND EXT_SYS_TYP_FLG = 'F1DB')
/

UPDATE CI_WFM SET EXT_SYS_TYP_FLG = 'F1DB' WHERE WFM_NAME = 'F1_DBCONINFO'
/

INSERT INTO CI_WFM_L ( WFM_NAME, LANGUAGE_CD,VERSION, DESCR) SELECT 'F1_DBCONINFO', 'ENG', 1, 'Database Connection Information' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM CI_WFM_L WHERE WFM_NAME = 'F1_DBCONINFO' AND LANGUAGE_CD = 'ENG')
/

UPDATE CI_WFM_L SET DESCR = 'Database Connection Information' WHERE WFM_NAME = 'F1_DBCONINFO' and language_cd = 'ENG'
/

INSERT INTO CI_WFM_OPT ( WFM_NAME, SEQ_NUM, VERSION, WFM_OPT_VAL,EXT_OPT_TYPE ) SELECT 'F1_DBCONINFO', 1, 1, ' ', 'F1DP' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM CI_WFM_OPT WHERE WFM_NAME = 'F1_DBCONINFO' AND EXT_OPT_TYPE = 'F1DP' AND SEQ_NUM = 1)
/

INSERT INTO CI_WFM_OPT ( WFM_NAME, SEQ_NUM, VERSION, WFM_OPT_VAL,EXT_OPT_TYPE ) SELECT 'F1_DBCONINFO', 1, 1, ' ', 'F1DU' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM CI_WFM_OPT WHERE WFM_NAME = 'F1_DBCONINFO' AND EXT_OPT_TYPE = 'F1DU' AND SEQ_NUM = 1)
/


__ENDIF__
