IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILL_SETTING') 
 CREATE TABLE T_ER_BILL_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ',
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(25) DEFAULT ' ' NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(10) DEFAULT ' ' NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX INT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX INT DEFAULT 0 NOT NULL,
FFORMTITLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREIMBURSETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILL_SETTING_ENTRY') 
 CREATE TABLE T_ER_BILL_SETTING_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFIELDNUMBER NVARCHAR(50) DEFAULT ' ',
FFIELDNAME NVARCHAR(50) DEFAULT ' ',
FDIYNAME NVARCHAR(50) DEFAULT ' ',
FFIELDTYPE NVARCHAR(10) DEFAULT ' ',
FLOCK CHAR(1) DEFAULT '0',
FLOCKCONDITION NVARCHAR(1024) DEFAULT ' ',
FMUSTINPUT CHAR(1) DEFAULT '0',
FHIDDEN CHAR(1) DEFAULT '0',
FLOCKCONDITIONJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLOCKCONDITIONJSON_TAG NCLOB DEFAULT ' ',
FLOCKCONDITIONEXPR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLOCKCONDITIONEXPR_TAG NCLOB DEFAULT ' '
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_BILL_SETTING_ENTRY_L') 
 CREATE TABLE T_ER_BILL_SETTING_ENTRY_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FDIYNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_SETTING_GROUP') 
 CREATE TABLE T_ER_SETTING_GROUP (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


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


 EXEC P_ALTERPK 'PK_T_ER_BILL_SETTING', 'T_ER_BILL_SETTING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_BILLSET_GROUP') CREATE INDEX IDX_ER_BILLSET_GROUP ON T_ER_BILL_SETTING ( FGROUPID );


 EXEC P_ALTERPK 'PK_T_ER_BILL_SETTING_ENTRY', 'T_ER_BILL_SETTING_ENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_BILL_SETTING_L', 'T_ER_BILL_SETTING_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_BILL_SETTING_ENTRY_L', 'T_ER_BILL_SETTING_ENTRY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BILLSETTING_FID') CREATE INDEX IDX_BILLSETTING_FID ON T_ER_BILL_SETTING_ENTRY_L ( FENTRYID );


 EXEC P_ALTERPK 'PK_T_ER_SETTING_GROUP', 'T_ER_SETTING_GROUP', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_SETTING_GROUP_L', 'T_ER_SETTING_GROUP_L', 'FPKID', '1';

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



