/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYMENTBILL_C') 
 CREATE TABLE T_CAS_PAYMENTBILL_C (
FID BIGINT DEFAULT 0 NOT NULL,
FISCROSSPAY CHAR(1) DEFAULT ' ' NOT NULL,
FCROSSTRANTYPEID BIGINT DEFAULT 0 NOT NULL,
FRECEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FRECBANKADDRESS VARCHAR(400) DEFAULT ' ' NOT NULL,
FCONTRACTNO VARCHAR(20) DEFAULT ' ' NOT NULL,
FAUDITPARAM VARCHAR(200) DEFAULT ' ' NOT NULL,
FTRANSTYPEID BIGINT DEFAULT 0 NOT NULL,
FPAYMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL,
FSERLEVEL VARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYPROXYBANKID BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSENDWAY VARCHAR(30) DEFAULT ' ' NOT NULL,
FCHECKUSE VARCHAR(30) DEFAULT ' ' NOT NULL,
FRECSWIFTCODE VARCHAR(100) DEFAULT ' ' NOT NULL,
FRECROUTINGNUM VARCHAR(100) DEFAULT ' ' NOT NULL,
FRECOTHERCODE VARCHAR(100) DEFAULT ' ' NOT NULL,
FFEEPAYER VARCHAR(30) DEFAULT ' ' NOT NULL,
FINSTRUCTMSG VARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYEECURRENCY BIGINT DEFAULT 0 NOT NULL,
FPAYCOUNTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FISDIFFCUR') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FISDIFFCUR CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPCURRENCY') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPCURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPEXRATETABLEID') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPEXRATETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPEXRATEDATE') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPEXCHANGERATE') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPEXCHANGERATE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPAMT') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FDPLOCALAMT') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FDPLOCALAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FAGREEDRATE') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FAGREEDRATE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FLOSSAMT') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FLOSSAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FFEE') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FFEE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FFEEACTBANK') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FFEEACTBANK BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL_E' AND KSQL_COL_NAME ='FFEECURRENCY') 
 ALTER TABLE T_CAS_PAYMENTBILL_E ADD (FFEECURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECEMAIL') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECBANKADDRESS') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECBANKADDRESS VARCHAR(400) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECSWIFTCODE') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECSWIFTCODE VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECROUTINGNUM') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECROUTINGNUM VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECOTHERCODE') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECOTHERCODE VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FPAYMETHOD') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FPAYMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FAUDITPARAM') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FAUDITPARAM VARCHAR(200) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FTRANSTYPEID') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FTRANSTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FCHECKTYPE') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FCHECKTYPE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FSENDWAY') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FSENDWAY VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FCHECKUSE') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FCHECKUSE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILLENTRY' AND KSQL_COL_NAME ='FRECCOUNTRYID') 
 ALTER TABLE T_CAS_AGENTPAYBILLENTRY ADD (FRECCOUNTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FISDIFFCUR') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FISDIFFCUR CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FDPCURRENCY') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FDPCURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FDPEXCHANGERATE') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FDPEXCHANGERATE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FDPAMT') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FDPAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FDPLOCALAMT') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FDPLOCALAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FAGREEDRATE') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FAGREEDRATE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FLOSSAMT') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FLOSSAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FFEE') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FFEE DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FFEEACTBANK') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FFEEACTBANK BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FFEECURRENCY') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FFEECURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FISCROSSPAY') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FISCROSSPAY CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FCONTRACTNO') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FCONTRACTNO VARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FFEEPAYER') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FFEEPAYER VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FSERLEVEL') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FSERLEVEL VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FINSTRUCTMSG') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FINSTRUCTMSG VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FPAYPROXYBANKID') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FPAYPROXYBANKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FCROSSTRANTYPEID') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FCROSSTRANTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AGENTPAYBILL_E' AND KSQL_COL_NAME ='FPAYCOUNTRYID') 
 ALTER TABLE T_CAS_AGENTPAYBILL_E ADD (FPAYCOUNTRYID BIGINT DEFAULT 0 NOT NULL );

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