IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILLINGPOOL_TYPE')
 CREATE TABLE T_ER_BILLINGPOOL_TYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FISINVOICE CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FREMARK NVARCHAR(2000) DEFAULT ' ',
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILLINGPOOL_TYPE_L')
 CREATE TABLE T_ER_BILLINGPOOL_TYPE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(2000) DEFAULT ' '
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILLPOOLCFG_L')
 CREATE TABLE T_ER_BILLPOOLCFG_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(2000) DEFAULT ' '
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILLPOOLCFG')
 CREATE TABLE T_ER_BILLPOOLCFG (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FEQUALCOSTCOMPANY CHAR(1) DEFAULT '0' NOT NULL,
FEQUALWL CHAR(1) DEFAULT '0' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FDUPEXPENSE VARCHAR(20) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FRANGOFSYNC VARCHAR(30) DEFAULT ' ' NOT NULL,
FPERIOD INT DEFAULT 0 NOT NULL,
FCANIMPORT CHAR(1) DEFAULT '0' NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(20) DEFAULT ' ' NOT NULL,
FBITINDEX INT DEFAULT 0 NOT NULL,
FSRCCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FISCROSSYEAR CHAR(1) DEFAULT '0' NOT NULL,
FCTLTYPE VARCHAR(20) DEFAULT ' ' NOT NULL,
FSOURCEBITINDEX INT DEFAULT 0 NOT NULL,
FCANMANUALADD CHAR(1) DEFAULT '0' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIQUECON VARCHAR(40) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(8) DEFAULT ' ' NOT NULL,
FUPTOMONTH varchar(8) DEFAULT ' ' NOT NULL,
FENABLEOFFSET CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


 EXEC P_ALTERPK 'PK_T_ER_BILLINGPOOL_TYPE', 'T_ER_BILLINGPOOL_TYPE', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_BILLINGPOOL_TYPE_L', 'T_ER_BILLINGPOOL_TYPE_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_BILLPOOLCFG_L', 'T_ER_BILLPOOLCFG_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_BILLPOOLCFG', 'T_ER_BILLPOOLCFG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BILLPOOLCFG_CREATER') CREATE INDEX IDX_BILLPOOLCFG_CREATER ON T_ER_BILLPOOLCFG ( FCREATEORGID );