/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_BANKSTATEMENT' AND KSQL_COL_NAME ='FTRANSTIME') 
 ALTER TABLE T_CAS_BANKSTATEMENT ADD (FTRANSTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECEIVINGBILL_E' AND KSQL_COL_NAME ='FREASON') 
 ALTER TABLE T_CAS_RECEIVINGBILL_E ADD (FREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECEIVINGBILL_E' AND KSQL_COL_NAME ='FBACKDATE') 
 ALTER TABLE T_CAS_RECEIVINGBILL_E ADD (FBACKDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECEIVINGBILL_E' AND KSQL_COL_NAME ='FBACKUSERID') 
 ALTER TABLE T_CAS_RECEIVINGBILL_E ADD (FBACKUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_RECEIVINGBILL_E' AND KSQL_COL_NAME ='FHOTACCOUNT') 
 ALTER TABLE T_CAS_RECEIVINGBILL_E ADD (FHOTACCOUNT CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_CAS_CLAIMBILL', 'FTRADEDETAILNO', 'NVARCHAR(50)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_CLAIMBILL', 'FHANDLESTATUS', 'NVARCHAR(30)', 'NOT NULL', '0001', '''0''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMBILL' AND KSQL_COL_NAME ='FCLAIMTYPE') 
 ALTER TABLE T_CAS_CLAIMBILL ADD (FCLAIMTYPE NVARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMBILL' AND KSQL_COL_NAME ='FCLAIMSTATUS') 
 ALTER TABLE T_CAS_CLAIMBILL ADD (FCLAIMSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMBILL' AND KSQL_COL_NAME ='FSOURCECLAIMID') 
 ALTER TABLE T_CAS_CLAIMBILL ADD (FSOURCECLAIMID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_CAS_CLAIMNOTICEBILL', 'FTRADEDETAILNO', 'NVARCHAR(50)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL' AND KSQL_COL_NAME ='FCONFIRMUSERID') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL ADD (FCONFIRMUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL' AND KSQL_COL_NAME ='FCHARGEREASON') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL ADD (FCHARGEREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL' AND KSQL_COL_NAME ='FCONFIRMDATE') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL ADD (FCONFIRMDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL' AND KSQL_COL_NAME ='FAPPEALME') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL ADD (FAPPEALME CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL_E' AND KSQL_COL_NAME ='FCLAIMTYPE') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL_E ADD (FCLAIMTYPE NVARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_CLAIMNOTICEBILL_E' AND KSQL_COL_NAME ='FBILLSTATUS') 
 ALTER TABLE T_CAS_CLAIMNOTICEBILL_E ADD (FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL );

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