/**Begin D:\PDM\pdm_upgrade\pdm1\ER_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIP_LOG')
CREATE TABLE T_ER_TRIP_LOG (
                               FID BIGINT DEFAULT 0 NOT NULL,
                               FUSERNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                               FOPNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                               FOPDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FOPDATE DATETIME,
                               FSERVER VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FFUNCTION VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FTRACEID VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
                               FMESSAGE VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FMESSAGE_TAG NCLOB DEFAULT ' ',
                               FREQUESTURL VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FREQUESTDATA VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FREQUESTDATA_TAG NCLOB DEFAULT ' ',
                               FRESPONSEDATA VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FRESPONSEDATA_TAG NCLOB DEFAULT ' ',
                               FBILLNO VARCHAR(255) DEFAULT ' ' NOT NULL,
                               FBILLNO_TAG NCLOB DEFAULT ' '
);



EXEC P_ALTERPK 'PK_T_ER_TRIP_LOG', 'T_ER_TRIP_LOG', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIPLOG_TTRIP') CREATE INDEX IDX_TRIPLOG_TTRIP ON T_ER_TRIP_LOG ( FTRACEID );

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIPLOG_SERVER') CREATE  CLUSTERED INDEX IDX_TRIPLOG_SERVER ON T_ER_TRIP_LOG ( FSERVER ,FFUNCTION );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIPLOGOPDATE') CREATE INDEX IDX_TRIPLOGOPDATE ON T_ER_TRIP_LOG ( FOPDATE );



