/**Begin D:\PDM_UPGRADE\PDM1\BEI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSDETAIL_L' AND KSQL_COL_NAME IN ('FERRORMSG'))
 ALTER TABLE T_BEI_TRANSDETAIL_L ADD (FERRORMSG NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSDETAIL' AND KSQL_COL_NAME IN ('FERRORTYPE'))
 ALTER TABLE T_BEI_TRANSDETAIL ADD (FERRORTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_TRANSDETAIL' AND KSQL_COL_NAME IN ('FERRORMSG'))
 ALTER TABLE T_BEI_TRANSDETAIL ADD (FERRORMSG NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_MISSRECORD')
 CREATE TABLE T_BEI_MISSRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS NVARCHAR(5) DEFAULT ' ' NOT NULL,
FBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTBANKID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FCHECKTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FCHECKRESULT CHAR(1) DEFAULT ' ' NOT NULL,
FCHECKRESULTDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FTRYNUM INT DEFAULT 0 NOT NULL,
FCOUNT INT DEFAULT 0 NOT NULL,
FLSTBALANCE DECIMAL(23,10),
FAMOUNT DECIMAL(23,10),
FDEBITTOTAL DECIMAL(23,10),
FCREDITTOTAL DECIMAL(23,10),
FBALANCE DECIMAL(23,10),
FDETAILTIME DATETIME,
FLSTBALANCETIME DATETIME,
FBALANCETIME DATETIME,
FLSTDATASOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FDATASOURCE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCORRECTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_MISSRECORDLOG')
 CREATE TABLE T_BEI_MISSRECORDLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLCOUNT INT DEFAULT 0 NOT NULL,
FLLSTBALANCE DECIMAL(23,10),
FLDEBITTOTAL DECIMAL(23,10),
FLCREDITTOTAL DECIMAL(23,10),
FLAMOUNT DECIMAL(23,10),
FLBALANCE DECIMAL(23,10),
FLCHECKRESULT CHAR(1) DEFAULT ' ' NOT NULL,
FLCHECKRESULTDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FEXECTIME DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL' AND KSQL_COL_NAME IN ('FPAYERADDRESS'))
ALTER TABLE T_BEI_BANKPAYINGBILL ADD (FPAYERADDRESS NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL' AND KSQL_COL_NAME IN ('FRECBANKADDS'))
ALTER TABLE T_BEI_BANKPAYINGBILL ADD (FRECBANKADDS NVARCHAR(255) DEFAULT ' ' NOT NULL );



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