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

__EXIT__

__ENDIF__


__IF_EXISTS__
SELECT 1
  FROM USER_TABLES
WHERE TABLE_NAME = 'F1_INSTALLATION'
/
__ELSE__

__EXIT__

__ENDIF__


__IF_EXISTS__
SELECT 1
  FROM USER_TABLES
WHERE TABLE_NAME = 'CI_XAI_SNDR_CTX'
/
__ELSE__

__EXIT__

__ENDIF__


__IF_EXISTS__
SELECT 1
  FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = 'CI_XAI_SNDR_CTX'
   AND COLUMN_NAME = 'SEQNO'
/

__ELSE__

ALTER TABLE CI_XAI_SNDR_CTX ADD  (SEQNO NUMBER(5) NULL )
/
__ENDIF__ 

UPDATE CI_XAI_SNDR_CTX SET SEQNO=ROWNUM WHERE SEQNO IS NULL
/
__IF_EXISTS__
SELECT 1
  FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = 'CI_XAI_SNDR_CTX'
   AND COLUMN_NAME = 'SEQNO'
   AND NULLABLE = 'Y'
/
ALTER TABLE CI_XAI_SNDR_CTX MODIFY (SEQNO NOT NULL)
/
ALTER TABLE CI_XAI_SNDR_CTX DROP PRIMARY KEY
/
__ENDIF__
