IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINE_DIMGROP') 
 CREATE TABLE T_EB_EXAMINE_DIMGROP (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINE_TEMP') 
 CREATE TABLE T_EB_EXAMINE_TEMP (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BGMD_BIZRULETAXES') 
 CREATE TABLE T_BGMD_BIZRULETAXES (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FRULE CHAR(1) DEFAULT '0' NOT NULL,
FTAXRATESHOW NVARCHAR(100) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FTAXRATECACL DECIMAL(23,2) DEFAULT 0 NOT NULL,
FOFFSET BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BGMD_PLANRULE') 
 CREATE TABLE T_BGMD_PLANRULE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDATATYPEID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FROOTIN CHAR(1) DEFAULT '1' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FCONFIRMRULE CHAR(1) DEFAULT '0' NOT NULL,
FHELPDIMNUMBER NVARCHAR(510) DEFAULT ' ' NOT NULL,
FEARNINGACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FDEPOSITACCCOUNTID BIGINT DEFAULT 0 NOT NULL,
FCASHFLOWACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FCANCELLATIONACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FAVTTAXRULEID BIGINT DEFAULT 0 NOT NULL,
FAVTPAYABLEACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FAVTCASHFLOWACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BGMD_PLANRULEENTITY') 
 CREATE TABLE T_BGMD_PLANRULEENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED1 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED2 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED3 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED4 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED5 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINED6 BIGINT DEFAULT 0 NOT NULL,
FMONTHLYPERIOD INT DEFAULT 0 NOT NULL,
FRATEPERIOD INT DEFAULT 0 NOT NULL,
FRETEPERIODDETAIL NVARCHAR(510) DEFAULT ' ' NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PRODETAIL' AND KSQL_COL_NAME ='FAMOUNTUNIT') 
 ALTER TABLE T_BGM_PRODETAIL ADD (FAMOUNTUNIT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGM_PROJECTAPPLY' AND KSQL_COL_NAME ='FHANDLER') 
 ALTER TABLE T_BGM_PROJECTAPPLY ADD (FHANDLER NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVEBILLENTRY') 
 CREATE TABLE T_EB_APPROVEBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FTEMPID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVEBILL') 
 CREATE TABLE T_EB_APPROVEBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FEBORGMASTERID BIGINT DEFAULT 0 NOT NULL,
FAPPROVEINFO NVARCHAR(510) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FBILLTYPE CHAR(1) DEFAULT '0' NOT NULL,
FEBORGID BIGINT DEFAULT 0 NOT NULL,
FAPPROVETEMPID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDIMENTITY BIGINT DEFAULT 0 NOT NULL,
FDIMDATATYPE BIGINT DEFAULT 0 NOT NULL,
FDIMACCOUNT BIGINT DEFAULT 0 NOT NULL,
FDIMYEAR BIGINT DEFAULT 0 NOT NULL,
FDIMPERIOD BIGINT DEFAULT 0 NOT NULL,
FDIMVERSION BIGINT DEFAULT 0 NOT NULL,
FAPPOROVERID BIGINT DEFAULT 0 NOT NULL,
FCREATERID BIGINT DEFAULT 0 NOT NULL,
FAPPROVEDATE DATETIME,
FCREATEDATE DATETIME,
FHANDLER BIGINT DEFAULT 0 NOT NULL
);
