IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FBIZITEM') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FBIZITEM BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FTREATTYPE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FTREATTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FMEETTYPE') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FMEETTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FMEETLEVEL') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FMEETLEVEL NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FCITYAREA') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FCITYAREA BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FREIMBURSELEVEL') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FREIMBURSELEVEL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FTREATNUM') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FTREATNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FESCORTNUM') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FESCORTNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FDAYSNUM') 
 ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FDAYSNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME ='FMEETGRADE')
ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FMEETGRADE NVARCHAR(10) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FBIZITEM') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FBIZITEM BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FTREATTYPE') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FTREATTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FMEETTYPE') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FMEETTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FMEETLEVEL') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FMEETLEVEL NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FCITYAREA') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FCITYAREA BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FREIMBURSELEVEL') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FREIMBURSELEVEL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FTREATNUM') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FTREATNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FESCORTNUM') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FESCORTNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FDAYSNUM') 
 ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FDAYSNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME ='FMEETGRADE')
ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FMEETGRADE NVARCHAR(10) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYDETAIL' AND KSQL_COL_NAME ='FMEETITEM') 
 ALTER TABLE T_ER_DAILYAPPLYDETAIL ADD (FMEETITEM 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 ='FMEETITEM') 
 ALTER TABLE T_ER_PUBREIMEXPDET_A ADD (FMEETITEM NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSEDETAIL' AND KSQL_COL_NAME ='FMEETITEM') 
 ALTER TABLE T_ER_EXPENSEDETAIL ADD (FMEETITEM NVARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_PUBREIMBILL_A') 
 CREATE TABLE T_ER_PUBREIMBILL_A (
FID BIGINT DEFAULT 0 NOT NULL,
FBIZITEM BIGINT DEFAULT 0 NOT NULL,
FTREATTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FMEETTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FMEETLEVEL NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCITYAREA BIGINT DEFAULT 0 NOT NULL,
FREIMBURSELEVEL BIGINT DEFAULT 0 NOT NULL,
FTREATNUM INT DEFAULT 0 NOT NULL,
FESCORTNUM INT DEFAULT 0 NOT NULL,
FDAYSNUM INT DEFAULT 0 NOT NULL,
FMEETGRADE NVARCHAR(10) DEFAULT ' ' NOT NULL
);


EXEC P_ALTERPK 'PK_T_ER_PUBREIMBILL_A', 'T_ER_PUBREIMBILL_A', 'FID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_A_BIZITEM') CREATE INDEX IDX_ER_PUBREIM_A_BIZITEM ON T_ER_PUBREIMBILL_A ( FBIZITEM );


