/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BEI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG' AND KSQL_COL_NAME IN ('FBIZEXCEPTIONINFO')) 
 ALTER TABLE T_BEI_BANKLOG ADD (FBIZEXCEPTIONINFO NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKLOG' AND KSQL_COL_NAME IN ('FBIZEXCEPTIONINFO_TAG')) 
 ALTER TABLE T_BEI_BANKLOG ADD (FBIZEXCEPTIONINFO_TAG NCLOB );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL' AND KSQL_COL_NAME IN ('FISPRIVATEPAY')) 
 ALTER TABLE T_BEI_BANKPAYINGBILL ADD (FISPRIVATEPAY CHAR(1) DEFAULT ' ' NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKPAYINGBILL' AND KSQL_COL_NAME IN ('FBANKPAYSTATE')) 
 ALTER TABLE T_BEI_BANKPAYINGBILL ADD (FBANKPAYSTATE VARCHAR(30) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKAGENTPAY_ENTRY') 
 CREATE TABLE T_BEI_BANKAGENTPAY_ENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRECNAME VARCHAR(50) DEFAULT '1' NOT NULL,
FRECBANK VARCHAR(50) DEFAULT '1' NOT NULL,
FACCTBANKNUM VARCHAR(50) DEFAULT '1' NOT NULL,
FRECAMOUNT VARCHAR(100) DEFAULT '1' NOT NULL,
FPROVINCE VARCHAR(50) DEFAULT '1' NOT NULL,
FCITY VARCHAR(50) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT '1' NOT NULL,
FBANKRETURNMSG VARCHAR(200) DEFAULT '1' NOT NULL,
FISREFUND CHAR(1) DEFAULT '1' NOT NULL,
FISAGENCYPERSONPAY CHAR(1) DEFAULT '1' NOT NULL,
FREMARK VARCHAR(200) DEFAULT '1' NOT NULL,
FBANKCHECKFLAG VARCHAR(80) DEFAULT '1' NOT NULL,
FSOURCEENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKAGENTPAYBILL' AND KSQL_COL_NAME IN ('FSERIALNUMBER')) 
 ALTER TABLE T_BEI_BANKAGENTPAYBILL ADD (FSERIALNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_BANKAGENTPAYBILL' AND KSQL_COL_NAME IN ('FSETTLETYPEID')) 
 ALTER TABLE T_BEI_BANKAGENTPAYBILL ADD (FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL );
 
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FDEBITAMOUNT')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FDEBITAMOUNT DECIMAL(19,6));
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FDEBITAMOUNT', 'DECIMAL(19,6)', 'NOT NULL', '0011', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FCREDITAMOUNT')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FCREDITAMOUNT DECIMAL(19,6));
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FCREDITAMOUNT', 'DECIMAL(19,6)', 'NOT NULL', '0011', '0';

 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FAMOUNT')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FAMOUNT DECIMAL(19,6));
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FAMOUNT', 'DECIMAL(19,6)', 'NOT NULL', '0011', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FLOCAMT')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FLOCAMT DECIMAL(19,6));
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FLOCAMT', 'DECIMAL(19,6)', 'NOT NULL', '0011', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BEI_ELECRECEIPT' AND KSQL_COL_NAME IN ('FEXCHANGERATE')) 
 ALTER TABLE T_BEI_ELECRECEIPT ADD (FEXCHANGERATE DECIMAL(19,6));
 EXEC p_AlterColumn 'T_BEI_ELECRECEIPT', 'FEXCHANGERATE', 'DECIMAL(23,10)', 'NOT NULL', '0011', '0';

 --- drop TABLE --------- 请认真检查该脚本 ------------------- 
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BEI_BANKAGENTPAYENTRY') 
 DROP TABLE T_BEI_BANKAGENTPAYENTRY;


/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BEI_table.sql **/
