/**Begin D:\PDM_UPGRADE\PDM1\TM_table.sql **/
--外汇添加授信字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE' AND KSQL_COL_NAME IN ('FISCREDITUSE'))
 ALTER TABLE T_TM_TRADE ADD (FISCREDITUSE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE' AND KSQL_COL_NAME IN ('FNEAREND'))
 ALTER TABLE T_TM_TRADE ADD (FNEAREND CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE' AND KSQL_COL_NAME IN ('FFAREND'))
 ALTER TABLE T_TM_TRADE ADD (FFAREND CHAR(1) DEFAULT '0' NOT NULL );
/**End D:\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_USERTABLES WHERE KSQL_TABNAME = 'T_TM_LIFECYCLEAPPLY') 
 CREATE TABLE T_TM_LIFECYCLEAPPLY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FAPPLYDATE DATETIME,
FDESCRIPTION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSELLCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRADEBILLID BIGINT DEFAULT 0 NOT NULL,
FTRADETYPEID BIGINT DEFAULT 0 NOT NULL,
FPAIR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLIFECYCLEOPERATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREMAININGUNEXPIREAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPDATE DATETIME,
FDELIVERYDATE DATETIME,
FBUYAMOUNTMAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBUYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELLAMOUNTMAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISCHOOSEDATE CHAR(1) DEFAULT '0' NOT NULL,
FEXPIREDATE DATETIME,
FEXPIREDATESTART DATETIME,
FEXPIREDATEEND DATETIME,
FTRADENUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRADEOPDATE DATETIME,
FTRADEDELIVERYDATE DATETIME,
FTRADEDELIVERYSTARTDATE DATETIME,
FTRADEDELIVERYENDDATE DATETIME,
FBDELIVERYRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRADESELLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRADEBUYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFORERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCLOSERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENTSELECTEDCARDINDEX BIGINT DEFAULT 0 NOT NULL,
FISGENARATEALREADY CHAR(1) DEFAULT '0' NOT NULL,
FCURRENTSELECTEDCARDID BIGINT DEFAULT 0 NOT NULL,
FDEFERRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSWAPTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFARORNEAR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSHOWBUYAMOUNT CHAR(1) DEFAULT '0' NOT NULL,
FSHOWSELLAMOUNT CHAR(1) DEFAULT '0' NOT NULL,
FDIRECTION NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_LIFECYCLEAPPLY_ENTRY') 
 CREATE TABLE T_TM_LIFECYCLEAPPLY_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDELIVERYDATE DATETIME,
FEXDATERANGE_START DATETIME,
FEXDATERANGE_END DATETIME,
FFORWARDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNEXPIREAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPOTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLIFECYCLECARDID BIGINT DEFAULT 0 NOT NULL
);



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