IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BGAPPLYBILL') 
CREATE TABLE T_EB_BGAPPLYBILL (	
	FID BIGINT DEFAULT 0 NOT NULL, 
	FORG BIGINT DEFAULT 0 NOT NULL, 
	FYEAR BIGINT DEFAULT 0 NOT NULL, 
	FBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL, 
	FAPPLYDATE DATETIME, 
	FPROPOSER BIGINT DEFAULT 0 NOT NULL, 
	FMONEYUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL, 
	FCREATER BIGINT DEFAULT 0 NOT NULL, 
	FCREATEDATE DATETIME, 
	FMODIFIER BIGINT DEFAULT 0 NOT NULL, 
	FMODIFYDATE DATETIME, 
	FAUDITOR BIGINT DEFAULT 0 NOT NULL, 
	FAPPLYSCHEME BIGINT DEFAULT 0 NOT NULL, 
	FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL , 
	FAUDITDATE DATETIME, 
	FMODELID BIGINT DEFAULT 0 NOT NULL, 
	FBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL , 
	FAUDITPATH NCLOB , 
	FCOLLECTORG BIGINT DEFAULT 0 NOT NULL, 
	 CONSTRAINT PK_EB_BGAPPLYBILL PRIMARY KEY (FID)
);
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_BGAPPLYBILL_p1')
CREATE INDEX IDX_EB_BGAPPLYBILL_p1 ON T_EB_BGAPPLYBILL (FMODELID,FAPPLYSCHEME ASC);




IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYSCHEMEALLOT') 
CREATE TABLE T_EB_APPLYSCHEMEALLOT(
  FID BIGINT DEFAULT 0 NOT NULL ,
  FMODEL BIGINT DEFAULT 0 NOT NULL ,
  FENTITY BIGINT DEFAULT 0 NOT NULL ,
  FTEMPLATE BIGINT DEFAULT 0 NOT NULL ,
  FRANGE NVARCHAR(50)  DEFAULT ' '  NOT NULL ,
  FTEXTNAME NVARCHAR(50) DEFAULT ' '  NOT NULL ,
   CONSTRAINT PK_EB_APPLYSCHEMEALLOT PRIMARY KEY (FID)
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_APPLYSCHEMEALLOT_p1')
CREATE INDEX IDX_EB_APPLYSCHEMEALLOT_p1 ON T_EB_APPLYSCHEMEALLOT (FMODEL ASC);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BGAPPLYSCHEME') 
CREATE TABLE T_EB_BGAPPLYSCHEME (
  FID BIGINT DEFAULT 0 NOT NULL  ,
  FNUMBER NVARCHAR(50) DEFAULT ' '  NOT NULL ,
  FBEGINTIME DATETIME ,
  FUSETIME BIGINT DEFAULT 0 NOT NULL ,
  FDEADLINE DATETIME  ,
  FISCLOSED CHAR(1) DEFAULT '1'  NOT NULL ,
  FCREATERID BIGINT DEFAULT 0 NOT NULL ,
  FCREATEDATE DATETIME ,
  FMODIFIERID BIGINT DEFAULT 0 NOT NULL ,
  FMODIFYDATE DATETIME ,
  FORGID BIGINT DEFAULT 0 NOT NULL ,
  FTASKLISTID BIGINT DEFAULT 0 NOT NULL ,
  FTASKSEQ BIGINT DEFAULT 0 NOT NULL ,
  FTASKTEMPLATE BIGINT DEFAULT 0 NOT NULL ,
  FMODELID BIGINT DEFAULT 0 NOT NULL ,
  FSCHEMELISTID BIGINT DEFAULT 0 NOT NULL ,
  FSCHEMESEQ BIGINT DEFAULT 0 NOT NULL ,
  FISACTIVE  CHAR(1) DEFAULT '1'  NOT NULL ,
   CONSTRAINT PK_EB_BGAPPLYSCHEME PRIMARY KEY (FID)
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_BGAPPLYSCHEME_p1')
CREATE INDEX IDX_EB_BGAPPLYSCHEME_p1 ON T_EB_BGAPPLYSCHEME (FMODELID,FSCHEMELISTID ASC);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BGAPPLYSCHEME_L') 
CREATE TABLE T_EB_BGAPPLYSCHEME_L (
  FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL ,
  FID BIGINT DEFAULT 0 NOT NULL   ,
  FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL ,
  FNAME NVARCHAR(50) DEFAULT ' '  NOT NULL ,
  FDESCRIPTION NVARCHAR(255) DEFAULT ' '  NOT NULL ,
   CONSTRAINT PK_EB_BGAPPLYSCHEME_L PRIMARY KEY (FPKID)
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYSCHEMEREFTEMP') 
CREATE TABLE T_EB_APPLYSCHEMEREFTEMP (
  FID BIGINT DEFAULT 0 NOT NULL   ,
  FENTRYID BIGINT DEFAULT 0 NOT NULL    ,
  FSEQ INT DEFAULT 0  NOT NULL ,
  FTEMPLATEID NVARCHAR(50) DEFAULT ' '  NOT NULL ,
  FTEMPLATETYPE NVARCHAR(50) DEFAULT ' '  NOT NULL ,
   CONSTRAINT PK_EB_APPLYSCHEMEREFTEMP PRIMARY KEY (FENTRYID)
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYSCHEMELIST') 
CREATE TABLE T_EB_APPLYSCHEMELIST(
  FID BIGINT DEFAULT 0 NOT NULL    ,
  FNUMBER NVARCHAR(50)  DEFAULT ' '  NOT NULL ,
  FDATETYPEID BIGINT DEFAULT 0 NOT NULL   ,
  FYEARID BIGINT DEFAULT 0 NOT NULL   ,
  FVERSIONID BIGINT DEFAULT 0 NOT NULL   ,
  FMODELID BIGINT DEFAULT 0 NOT NULL   ,
  FCREATERID BIGINT DEFAULT 0 NOT NULL   ,
  FCREATEDATE DATETIME,
  FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL   ,
  FMODIFYDATE DATETIME,
  FORGID BIGINT DEFAULT 0 NOT NULL   ,
  FSTATE NVARCHAR(1)  DEFAULT ' '  NOT NULL ,
  FBIZMODELID BIGINT DEFAULT 0 NOT NULL   ,
  FBIZCTRLRANGEID BIGINT DEFAULT 0 NOT NULL   ,
  CONSTRAINT PK_EB_APPLYSCHEMELIST PRIMARY KEY (FID)
);
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_APPLYSCHEMELIST_p1')
CREATE INDEX IDX_EB_APPLYSCHEMELIST_p1 ON T_EB_APPLYSCHEMELIST (FMODELID,FBIZCTRLRANGEID ASC);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYSCHEMELIST_L') 
CREATE TABLE T_EB_APPLYSCHEMELIST_L (
  FPKID NVARCHAR(36)  NOT NULL ,
  FID BIGINT DEFAULT 0 NOT NULL   ,
  FLOCALEID VARCHAR(10)  NOT NULL ,
  FNAME NVARCHAR(50)  DEFAULT ' '  NOT NULL ,
  FDESCRIPTION NVARCHAR(100)  DEFAULT ' '  NOT NULL ,
  CONSTRAINT PK_EB_APPLYSCHEMELIST_L PRIMARY KEY (FPKID)
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYSCHEMEVARIABLE') 
CREATE TABLE T_EB_APPLYSCHEMEVARIABLE (
  FID BIGINT DEFAULT 0 NOT NULL   ,
  FENTRYID BIGINT DEFAULT 0 NOT NULL   ,
  FSEQ INT  DEFAULT 0  NOT NULL ,
  FDIMENSION BIGINT DEFAULT 0 NOT NULL   ,
  FVARIABLENUMBER BIGINT DEFAULT 0 NOT NULL   ,
  FVARIABLE NVARCHAR(50)  DEFAULT ' '  NOT NULL ,
  FVARIABLEJSONTEXT NVARCHAR(255)  DEFAULT ' '  NOT NULL ,
    CONSTRAINT PK_EB_APPLYSCHEMEVARIABLE PRIMARY KEY (FENTRYID)
);




