/**Begin D:\softwaresetup\PDM_UPGRADE\PDM1\CAS_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FBACKBILLFLAG')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FBACKBILLFLAG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FPARTPAYSCHE')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FPARTPAYSCHE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FPARTPAY')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FPARTPAY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FINVALIDFLAG')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FINVALIDFLAG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FSCHEUSER')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FSCHEUSER BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FPRIORITY')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FEACCOUNTNAME')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FEACCOUNTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FCHGSTATUS')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FCHGSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FECHGPAYEEACCBANK')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FECHGPAYEEACCBANK BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FECHGPAYEEACCBANKID')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FECHGPAYEEACCBANKID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FECHGPAYEEACCBANKNUM')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FECHGPAYEEACCBANKNUM NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FECHGUSERACCBANK')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FECHGUSERACCBANK BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FECHGPAYEEBANKID')) 
 ALTER TABLE T_CAS_PAYAPPLYENTRY ADD (FECHGPAYEEBANKID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYINFOENTRY' AND KSQL_COL_NAME IN ('FLASTMODIFYTIME')) 
 ALTER TABLE T_CAS_PAYINFOENTRY ADD (FLASTMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYINFOENTRY' AND KSQL_COL_NAME IN ('FEACCOUNTNAME')) 
 ALTER TABLE T_CAS_PAYINFOENTRY ADD (FEACCOUNTNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYINFOENTRY' AND KSQL_COL_NAME IN ('FRECSWIFTCODE')) 
 ALTER TABLE T_CAS_PAYINFOENTRY ADD (FRECSWIFTCODE NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYINFOENTRY' AND KSQL_COL_NAME IN ('FRECROUTINGNUM')) 
 ALTER TABLE T_CAS_PAYINFOENTRY ADD (FRECROUTINGNUM NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYINFOENTRY' AND KSQL_COL_NAME IN ('FRECOTHERCODE')) 
 ALTER TABLE T_CAS_PAYINFOENTRY ADD (FRECOTHERCODE NVARCHAR(50) DEFAULT ' ' NOT NULL );

/**End D:\softwaresetup\PDM_UPGRADE\PDM1\CAS_table.sql **/
