
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYDETAIL' AND KSQL_COL_NAME ='FWHITEML') 
 ALTER TABLE T_ER_DAILYAPPLYDETAIL ADD (FWHITEML INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYDETAIL' AND KSQL_COL_NAME ='FREDML') 
 ALTER TABLE T_ER_DAILYAPPLYDETAIL ADD (FREDML INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYDETAIL' AND KSQL_COL_NAME ='FOTHERCONTROLAMT') 
 ALTER TABLE T_ER_DAILYAPPLYDETAIL ADD (FOTHERCONTROLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYDETAIL' AND KSQL_COL_NAME ='FWINEWAY') 
 ALTER TABLE T_ER_DAILYAPPLYDETAIL ADD (FWINEWAY NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FWHITEML') 
 ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FWHITEML INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FREDML') 
 ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FREDML INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FOTHERCONTROLAMT') 
 ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FOTHERCONTROLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMEXPDET_A' AND KSQL_COL_NAME ='FWINEWAY') 
 ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FWINEWAY NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_EXPENSEDETAIL_A') 
 CREATE TABLE T_ER_EXPENSEDETAIL_A (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FWHITEML INT DEFAULT 0 NOT NULL,
FREDML INT DEFAULT 0 NOT NULL,
FOTHERCONTROLAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWINEWAY NVARCHAR(10) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_ER_EXPENSEDETAIL_A', 'T_ER_EXPENSEDETAIL_A', 'FDETAILID', '1';

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


