IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_RULE_INSTANCE') 
 CREATE TABLE T_EB_RULE_INSTANCE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FTEMPLATE BIGINT DEFAULT 0 NOT NULL,
FCURENTORG NVARCHAR(100) NOT NULL DEFAULT ' ',
FEXETYPE CHAR(1) NOT NULL DEFAULT ' ',
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FLASTTIME DATETIME,
FEXEGRAPH NCLOB,
FRULECOUNT INT DEFAULT 0 NOT NULL,
FSYNCCOUNT INT DEFAULT 0 NOT NULL,
FSYNCRULE NCLOB,
FASYNCCOUNT INT DEFAULT 0 NOT NULL,
FASYNCRULE NCLOB,
FEXECUTESTATUS CHAR(1) NOT NULL DEFAULT ' ',
FEXECUTELOG NCLOB,
FRELTEMPLATE NCLOB
);

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



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_RULE_INSTANCE_DETAIL') 
 CREATE TABLE T_EB_RULE_INSTANCE_DETAIL (
FLOGID BIGINT DEFAULT 0 NOT NULL,
FRULE BIGINT DEFAULT 0 NOT NULL,
FPREDECESSORS NCLOB,
FSUCCESSORS NCLOB,
FRELTEMPLATE NCLOB,
FEXESCOPE NCLOB,
FRESULTEXAMPLE NCLOB,
FEXECUTELOG NCLOB,
FCREATETIME DATETIME);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_RULEINSTANCE_DET')
CREATE INDEX IDX_EB_RULEINSTANCE_DET ON T_EB_RULE_INSTANCE_DETAIL (
FLOGID ASC
);


