/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPSYNCSETTING_L') 
 CREATE TABLE T_ER_TRIPSYNCSETTING_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPSYNCLOG') 
 CREATE TABLE T_ER_TRIPSYNCLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FSERVER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FFUNCTION VARCHAR(300) DEFAULT ' ' NOT NULL,
FTRACEID VARCHAR(300) DEFAULT ' ' NOT NULL,
FSYNCTIME DATETIME DEFAULT {ts'1970-01-01 00:00:00'},
FMESSAGE NCLOB,
FMESSAGE_TAG NCLOB,
FREQUESTURL VARCHAR(300),
FREQUESTDATA NCLOB,
FREQUESTDATA_TAG NCLOB,
FRESPONSEDATA NCLOB,
FRESPONSEDATA_TAG NCLOB,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLNO VARCHAR(300) DEFAULT '1970-01-01 00:00:00',
FBILLID VARCHAR(300)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPSYNCSETTING') 
 CREATE TABLE T_ER_TRIPSYNCSETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(200) DEFAULT ' ' NOT NULL,
FVALUE NVARCHAR(200) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);

 EXEC P_ALTERPK 'PK_T_ER_TRIPSYNCSETTING_L', 'T_ER_TRIPSYNCSETTING_L', 'FPKID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'T_ER_TRIPSYNCSETTING_L_FID') CREATE UNIQUE  CLUSTERED INDEX T_ER_TRIPSYNCSETTING_L_FID ON T_ER_TRIPSYNCSETTING_L ( FID );


 EXEC P_ALTERPK 'PK_ER_TRIPSYNCLOG', 'T_ER_TRIPSYNCLOG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIPSYNCLOG_FSERVER') CREATE INDEX IDX_TRIPSYNCLOG_FSERVER ON T_ER_TRIPSYNCLOG ( FSERVER );


 EXEC P_ALTERPK 'PK_T_ER_TRIPSYNCSETTING', 'T_ER_TRIPSYNCSETTING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIPSYNCSETTING_NUMBER') CREATE INDEX IDX_TRIPSYNCSETTING_NUMBER ON T_ER_TRIPSYNCSETTING ( FNUMBER );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_table.sql **/
