IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_WRITEOFFTRIPRELATE') 
 CREATE TABLE T_ER_WRITEOFFTRIPRELATE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FWRITEOFFENTRYID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEID BIGINT DEFAULT 0 NOT NULL
);

 EXEC P_ALTERPK 'PK_T_ER_WRITEOFFTRIPRELATE', 'T_ER_WRITEOFFTRIPRELATE', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WRITEOFFTRIPRELATE_FID') CREATE INDEX IDX_ER_WRITEOFFTRIPRELATE_FID ON T_ER_WRITEOFFTRIPRELATE ( FID );