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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_COMBTRADE' AND KSQL_COL_NAME IN ('FREQNOTENO'))
 ALTER TABLE T_TM_COMBTRADE ADD (FREQNOTENO NVARCHAR(80) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_COMBREQNOTE')
 CREATE TABLE T_TM_COMBREQNOTE (
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,
FAPPLYDATE DATETIME,
FLIMITNO BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCOMPOSEAUDIT CHAR(1) DEFAULT '0' NOT NULL,
FCOMPOSENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRICERULEID BIGINT DEFAULT 0 NOT NULL,
FISALLLGENBILL CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_COMBREQNOTE_FWD')
 CREATE TABLE T_TM_COMBREQNOTE_FWD (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FISOPTIONALTRACTION CHAR(1) DEFAULT '0' NOT NULL,
FDELIVERYDATE DATETIME,
FDELIVERYSTARTDATE DATETIME,
FDELIVERYENDDATE DATETIME,
FBIZTYPE NVARCHAR(50) 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,
FFOCOUNTERPARTYID BIGINT DEFAULT 0 NOT NULL,
FDELIVERYWAY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFWDFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFOPRICERULEID BIGINT DEFAULT 0 NOT NULL,
FEXPRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FTRANSACTIONNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORWARDSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFOFINALBIZDATE DATETIME,
FFWDEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FADJUSTDELIVERYDATE DATETIME,
FADSTARTDATE DATETIME,
FADENDDATE DATETIME,
FFOFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFOFINALAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFOFINCURRIN BIGINT DEFAULT 0 NOT NULL,
FFOFINCURROUT BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FFWDBILLID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_COMBREQNOTE_OPTIONS')
 CREATE TABLE T_TM_COMBREQNOTE_OPTIONS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FDELIVERYDATE DATETIME,
FBUSTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FOUTCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPTIONTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPDIRECT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRADEDIRECT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FDELMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFOPRICERULE1 BIGINT DEFAULT 0 NOT NULL,
FOPCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FOPFEEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPFEETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FOPTIONSBILLID BIGINT DEFAULT 0 NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_COMBREQNOTE_SPOT')
 CREATE TABLE T_TM_COMBREQNOTE_SPOT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FSPOTDELIVERYDATE DATETIME,
FBIZTYPE NVARCHAR(50) 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,
FCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FSPOTFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPPRICERULEID BIGINT DEFAULT 0 NOT NULL,
FEXPECTRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPECTRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FTRANSACTIONNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPOTSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFINALBIZDATE DATETIME,
FSPOTEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FSPOTDELDATE DATETIME,
FFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPFINCURRIN BIGINT DEFAULT 0 NOT NULL,
FSPFINCURROUT BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSPOTBILL BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_COMBREQNOTE_SWAPS')
 CREATE TABLE T_TM_COMBREQNOTE_SWAPS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FEND NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FSETTLEDATE DATETIME,
FBIZTYPE NVARCHAR(50) 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,
FCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSWPRICERULE BIGINT DEFAULT 0 NOT NULL,
FEXRATEBOTTOM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATETOP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBIZBILL CHAR(1) DEFAULT '0' NOT NULL,
FBIZBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFINALBIZDATE DATETIME,
FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFINALCOUNPTYID BIGINT DEFAULT 0 NOT NULL,
FDELIDATE DATETIME,
FFINALAMTIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMTOUT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSWFINCURRIN BIGINT DEFAULT 0 NOT NULL,
FSWFINCURROUT BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSWAPSBILLID BIGINT DEFAULT 0 NOT NULL
);



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