/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXECUTECASERECORD') 
CREATE TABLE T_EB_EXECUTECASERECORD (
   FID                  BIGINT               NOT NULL DEFAULT 0,
   FCASENUMBER          NVARCHAR(50)         NOT NULL DEFAULT ' ',
   FCASENAME            NVARCHAR(50)         NOT NULL DEFAULT ' ',
   FEXECUTEPROGRESS     NVARCHAR(50)         NOT NULL DEFAULT ' ',
   FRULEAMOUNT          BIGINT               NOT NULL DEFAULT 0,
   FEXECUTERULEAMOUNT   BIGINT               NOT NULL DEFAULT 0,
   FCREATORID             BIGINT               NOT NULL DEFAULT 0,
   FCREATETIME          DATETIME             ,
   FLASTTIME            DATETIME             ,
   FCANCELOR            BIGINT               NOT NULL DEFAULT 0,
   FEXECUTESTATUS       CHAR(1)              NOT NULL DEFAULT '1',
   FEXECUTELOG          NCLOB                ,
   FMODELID             BIGINT               NOT NULL DEFAULT 0,
   fcase 		BIGINT               NOT NULL DEFAULT 0
);

 EXEC P_ALTERPK 'PK_T_EB_EXECUTECASERECORD', 'T_EB_EXECUTECASERECORD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASERECORD_P1')
CREATE INDEX IDX_EB_EXECUTECASERECORD_P1 ON T_EB_EXECUTECASERECORD (
FCASENUMBER ASC
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASERECORD_P2')
CREATE INDEX IDX_EB_EXECUTECASERECORD_P2 ON T_EB_EXECUTECASERECORD (
FMODELID ASC
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASERECORD_P3')
CREATE INDEX IDX_EB_EXECUTECASERECORD_P3 ON T_EB_EXECUTECASERECORD (
FEXECUTESTATUS ASC
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXECUTECASE') 
CREATE TABLE T_EB_EXECUTECASE (
   FID                  BIGINT               NOT NULL DEFAULT 0,
   FNUMBER              NVARCHAR(50)         NOT NULL DEFAULT ' ',
   FNAME                NVARCHAR(50)         NOT NULL DEFAULT ' ',
   FMODELID             BIGINT               NOT NULL DEFAULT 0,
   FBUSINESSMODELID     BIGINT               NOT NULL DEFAULT 0,
   FRULEAMOUNT          BIGINT               NOT NULL DEFAULT 0,
   FCREATETIME          DATETIME             ,
   FMODIFYTIME          DATETIME             ,
   FCREATORID           BIGINT               NOT NULL DEFAULT 0,
   FMODIFIERID          BIGINT               NOT NULL DEFAULT 0                  
);

 EXEC P_ALTERPK 'PK_T_EB_EXECUTECASE', 'T_EB_EXECUTECASE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASE_P1')
CREATE INDEX IDX_EB_EXECUTECASE_P1 ON T_EB_EXECUTECASE (
FMODELID ASC,
FBUSINESSMODELID ASC
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXECUTECASE_RULE') 
CREATE TABLE T_EB_EXECUTECASE_RULE (
   FENTRYID             BIGINT               NOT NULL DEFAULT 0,
   FID                  BIGINT               NOT NULL DEFAULT 0,
   FSEQ                 BIGINT               NOT NULL DEFAULT 0,
   FBIZRULEID           BIGINT               NOT NULL DEFAULT 0,
   FSCOPE               NCLOB                     
);

 EXEC P_ALTERPK 'PK_T_EB_EXECUTECASE_RULE', 'T_EB_EXECUTECASE_RULE', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASE_RULE_P1')
CREATE INDEX IDX_EB_EXECUTECASE_RULE_P1 ON T_EB_EXECUTECASE_RULE (
FID ASC
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASE_RULE_P2')
CREATE INDEX IDX_EB_EXECUTECASE_RULE_P2 ON T_EB_EXECUTECASE_RULE (
FSEQ ASC
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXECUTECASE_RULE_P3')
CREATE INDEX IDX_EB_EXECUTECASE_RULE_P3 ON T_EB_EXECUTECASE_RULE (
FBIZRULEID ASC
);










/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
