/**Begin C:\Users\rd_zhixiong_w\Downloads\PDM_UPGRADE\PDM1\TBO_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TBO_PLINFO_ENTRYS' AND KSQL_COL_NAME IN ('FBIZBILLAMT')) 
 ALTER TABLE T_TBO_PLINFO_ENTRYS ADD (FBIZBILLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TBO_PLINFO_ENTRYS' AND KSQL_COL_NAME IN ('FBIZBILLVOUCHERPL')) 
 ALTER TABLE T_TBO_PLINFO_ENTRYS ADD (FBIZBILLVOUCHERPL DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TBO_PLINFO_E') 
 CREATE TABLE T_TBO_PLINFO_E (
FID BIGINT DEFAULT 0 NOT NULL,
FBUYCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSELLCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSTANDARDCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBUYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUPDATEDATE DATETIME,
FBUY_LOCAL_FQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUY_LOCAL_EXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELL_LOCAL_FQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSELL_LOCAL_EXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBIZRESTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVOUCHER_PL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACT_FLOATPLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLCALCMETHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORWRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCYRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICECURRENCYRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVOLATILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPTIONTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPREMIUMCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPREMIUM DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TBO_PLINFO_HISTORY') 
 CREATE TABLE T_TBO_PLINFO_HISTORY (
FID BIGINT DEFAULT 0 NOT NULL,
FPLBILLID BIGINT DEFAULT 0 NOT NULL,
FTRADEBILLID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FTRADETYPEID BIGINT DEFAULT 0 NOT NULL,
FOPTIONTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSWAPDIR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZRECORDID BIGINT DEFAULT 0 NOT NULL,
FSRCBIZBILLID BIGINT DEFAULT 0 NOT NULL,
FBIZBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBIZOP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYCURRENCY BIGINT DEFAULT 0 NOT NULL,
FSELLCURRENCY BIGINT DEFAULT 0 NOT NULL,
FBUYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELLAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDCURRENCY BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPLCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPLCALCMETHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYYIELDS BIGINT DEFAULT 0 NOT NULL,
FRECYIELDS BIGINT DEFAULT 0 NOT NULL,
FLASTOBSDATE DATETIME,
FFOREXQUOTEID BIGINT DEFAULT 0 NOT NULL,
FYIELDCURVEID BIGINT DEFAULT 0 NOT NULL,
FFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUPDATEDATE DATETIME,
FREFEREXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALFXQUOTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLOCALEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBUY_LOCAL_FQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUY_LOCAL_EXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSELL_LOCAL_FQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSELL_LOCAL_EXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFORWRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPOTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVOLATILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCYRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICECURRENCYRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREFERPREMIUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFLOATPLAMTCALCDATE DATETIME,
FPAYFLOATPLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECFLOATPLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPREMIUMCURRENCY BIGINT DEFAULT 0 NOT NULL,
FPREMIUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBIZRESTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFLOATPLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFLOATPLLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVOUCHER_PL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACT_FLOATPLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSPLCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FISSUEDATE DATETIME
);



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