IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYVEHICLEBILL_L')
CREATE TABLE T_ER_DAILYVEHICLEBILL_L (
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                         FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FAPPLIERPOSITION VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYVEHICLEBILL')
CREATE TABLE T_ER_DAILYVEHICLEBILL (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
                                       FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FBIZDATE DATETIME,
                                       FCOSTDEPTID BIGINT DEFAULT 0 NOT NULL,
                                       FCOSTCOMPANYID BIGINT DEFAULT 0 NOT NULL,
                                       FDESCRIPTION VARCHAR(600) DEFAULT ' ' NOT NULL,
                                       FAUDITDATE DATETIME,
                                       FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                       FCREATETIME DATETIME,
                                       FMODIFYTIME DATETIME,
                                       FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                       FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                       FBILLSTATUS VARCHAR(30) DEFAULT 'A' NOT NULL,
                                       FSTARTDATE DATETIME,
                                       FENDDATE DATETIME,
                                       FVEHICLENUMBER BIGINT DEFAULT 1 NOT NULL,
                                       FVEHICLECITY BIGINT DEFAULT 0 NOT NULL,
                                       FFROM VARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FTO VARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FORGID BIGINT DEFAULT 0 NOT NULL,
                                       FAPPLIERID BIGINT DEFAULT 0 NOT NULL,
                                       FAPPLIERPOSITION VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FNEXTAUDITOR VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FTEL VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FFORMID VARCHAR(50) DEFAULT ' ' NOT NULL
);


EXEC P_ALTERPK 'PK_T_ER_DAILYVEHICLEBILL_L', 'T_ER_DAILYVEHICLEBILL_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_VEHICLEBILL_L_FID_L') CREATE INDEX IDX_VEHICLEBILL_L_FID_L ON T_ER_DAILYVEHICLEBILL_L ( FID ,FLOCALEID );
EXEC P_ALTERPK 'PK_T_ER_DAILYVEHICLEBILL', 'T_ER_DAILYVEHICLEBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_VEHICLE_FBILLNO_STATUS') CREATE INDEX IDX_VEHICLE_FBILLNO_STATUS ON T_ER_DAILYVEHICLEBILL ( FBILLNO ,FBILLSTATUS );
