/**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_RECONCILIATION_E' AND KSQL_COL_NAME IN ('FSEQ')) 
 ALTER TABLE T_CAS_RECONCILIATION_E ADD (FSEQ BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CAS_RECE_STATUSORGID') CREATE INDEX IDX_CAS_RECE_STATUSORGID ON T_CAS_RECEIVINGBILL ( FBILLSTATUS ,FORGID );

 EXEC P_ALTERPK 'PK_T_CAS_RECONCILIATION_E', 'T_CAS_RECONCILIATION_E', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'INDEX_CAS_RULE_FID') CREATE INDEX INDEX_CAS_RULE_FID ON T_CAS_RECONCILIATION_E ( FID );


 EXEC P_ALTERPK 'PK_T_CAS_RECONCILIATIONRULE', 'T_CAS_RECONCILIATIONRULE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CAS_RULE_FNUMBER') CREATE INDEX IDX_CAS_RULE_FNUMBER ON T_CAS_RECONCILIATIONRULE ( FNUMBER );


 EXEC p_AlterColumn 'T_BE_TRANSDETAIL', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BE_TRANSDETAIL', 'FOPPBANKNUMBER', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BE_TRANSDETAIL', 'FOPPBANK', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_CASHJOURNAL', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_CASHJOURNAL', 'FOPPACCTNUMBER', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_CASHJOURNAL', 'FOPPBANK', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKSTATEMENT', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKSTATEMENT', 'FOPPACCOUNTNUMBER', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKSTATEMENT', 'FOPPBANK', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_ELECRECEIPT', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_ELECRECEIPT', 'FOPPBANKNUMBER', 'VARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_ELECRECEIPT', 'FOPPBANK', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKJOURNAL', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKJOURNAL', 'FOPPACCTNUMBER', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_BANKJOURNAL', 'FOPPBANK', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_CAS_CHECKEDRESULTENTRY', 'FOPPUNIT', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYCHGBILLENTRY' AND KSQL_COL_NAME ='FCHANGERECACCTBANK') 
 ALTER TABLE T_CAS_PAYCHGBILLENTRY ADD (FCHANGERECACCTBANK NVARCHAR(100) DEFAULT ' ' NOT NULL );
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\CAS_table.sql **/
