/**Begin D:\PDM_UPGRADE\PDM1\TM_table.sql **/
--交易外汇添加申请单号
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FREQNOTENO'))
 ALTER TABLE T_TM_TRADE_F ADD (FREQNOTENO NVARCHAR(80) DEFAULT ' ' NOT NULL );
--生命周期单添加申请单号
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_BUSINESSBILL' AND KSQL_COL_NAME IN ('FAPPLYNO'))
 ALTER TABLE T_TM_BUSINESSBILL ADD (FAPPLYNO NVARCHAR(80) DEFAULT ' ' NOT NULL );
--生命周期单添加本位币
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_BUSINESSBILL' AND KSQL_COL_NAME IN ('FBASECURRENCYID'))
 ALTER TABLE T_TM_BUSINESSBILL ADD (FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL );
--交易申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQNOTE')
 CREATE TABLE T_TM_REQNOTE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) 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,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPRODUCTTYPE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQNOTE_SPOT')
 CREATE TABLE T_TM_REQNOTE_SPOT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FOUTCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPECTRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPECTRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPOTDELIVERYDATE DATETIME,
FTRANSACTIONNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSPOTEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPOTDELDATE DATETIME,
FSPOTFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPOTSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FFINALBIZDATE DATETIME,
FSPPRICERULEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQNOTE_FWD')
 CREATE TABLE T_TM_REQNOTE_FWD (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FOUTCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMOUNTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISOPTIONALTRACTION CHAR(1) DEFAULT ' ' NOT NULL,
FDELIVERYDATE DATETIME,
FDELIVERYSTARTDATE DATETIME,
FDELIVERYENDDATE DATETIME,
FTRANSACTIONNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FFWDEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTDELIVERYDATE DATETIME,
FADSTARTDATE DATETIME,
FADENDDATE DATETIME,
FFWDFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORWARDSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FFOCOUNTERPARTYID BIGINT DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FFOFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFOFINALAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFOFINALBIZDATE DATETIME,
FFOPRICERULEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQNOTE_SWAPS')
 CREATE TABLE T_TM_REQNOTE_SWAPS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FINCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FOUTCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FSETTLEDATE DATETIME,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FBIZBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIDATE DATETIME,
FFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEND NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FSWPRICERULE BIGINT DEFAULT 0 NOT NULL,
FFINALBIZDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_REQNOTE' AND KSQL_COL_NAME IN ('FPRICERULEID'))
ALTER TABLE T_TM_REQNOTE ADD (FPRICERULEID BIGINT 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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_LIFECYCLEAPPLY_ENTRY' AND KSQL_COL_NAME IN ('FCARDTITLE')) 
 ALTER TABLE T_TM_LIFECYCLEAPPLY_ENTRY ADD (FCARDTITLE NVARCHAR(50) DEFAULT ' ' NOT NULL );

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