/**Begin C:\Users\rd_zhixiong_w\Downloads\PDM_UPGRADE\PDM1\TM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SETTING_L')
 CREATE TABLE T_TM_SETTLEMENT_SETTING_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SET_FOREX')
 CREATE TABLE T_TM_SETTLEMENT_SET_FOREX (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FFOREX_SETTING NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFOREX_MODULE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFOREX_OP NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SET_RATE')
 CREATE TABLE T_TM_SETTLEMENT_SET_RATE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRATE_MODULE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRATE_OP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRATE_SETTING NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SET_STRUC')
 CREATE TABLE T_TM_SETTLEMENT_SET_STRUC (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTRUCT_MODULE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTRUCT_OP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTRUCT_SETTING NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SETTING')
 CREATE TABLE T_TM_SETTLEMENT_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLEDATE DATETIME,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_SETTLEMENT_SET_ORG')
 CREATE TABLE T_TM_SETTLEMENT_SET_ORG (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



/**End C:\Users\rd_zhixiong_w\Downloads\PDM_UPGRADE\PDM1\TM_table.sql **/

/**Begin C:\Users\rd_zhixiong_w\Downloads\PDM_UPGRADE\PDM1\TM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_BUSINESSBILL' AND KSQL_COL_NAME IN ('FPAYBIZAMT1'))
 ALTER TABLE T_TM_BUSINESSBILL ADD (FPAYBIZAMT1 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_BUSINESSBILL' AND KSQL_COL_NAME IN ('FPAYBIZAMT2'))
 ALTER TABLE T_TM_BUSINESSBILL ADD (FPAYBIZAMT2 DECIMAL(23,10) DEFAULT 0 NOT NULL );

/**End C:\Users\rd_zhixiong_w\Downloads\PDM_UPGRADE\PDM1\TM_table.sql **/

/**Begin D:\PDM_UPGRADE\PDM1\TM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_E' AND KSQL_COL_NAME IN ('FVOUCHERPL'))
 ALTER TABLE T_TM_TRADE_E ADD (FVOUCHERPL DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_E' AND KSQL_COL_NAME IN ('FRECLOCALEXRATE'))
 ALTER TABLE T_TM_TRADE_E ADD (FRECLOCALEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_E' AND KSQL_COL_NAME IN ('FPAYLOCALFQ'))
 ALTER TABLE T_TM_TRADE_E ADD (FPAYLOCALFQ NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_E' AND KSQL_COL_NAME IN ('FPAYLOCALEXRATE'))
 ALTER TABLE T_TM_TRADE_E ADD (FPAYLOCALEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_E' AND KSQL_COL_NAME IN ('FRECLOCALFQ'))
 ALTER TABLE T_TM_TRADE_E ADD (FRECLOCALFQ NVARCHAR(50) DEFAULT ' ' NOT NULL );

/**End D:\PDM_UPGRADE\PDM1\TM_table.sql **/
