IF
NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_MULIMP_RESULTTREE')
CREATE TABLE T_BAS_MULIMP_RESULTTREE
(
    FID                   BIGINT       DEFAULT 0   NOT NULL,
    FENTRYID              BIGINT       DEFAULT 0   NOT NULL,
    FSEQ                  INT          DEFAULT 0   NOT NULL,
    FPARENTENTRYID        BIGINT       DEFAULT 0   NOT NULL,
    FNAME                 NVARCHAR(255) DEFAULT ' ' NOT NULL,
    FDATASHEETNAME        NVARCHAR(100) DEFAULT ' ' NOT NULL,
    FIMPORTTYPE           CHAR(1)      DEFAULT '0' NOT NULL,
    FDATAREPLACERULEFIELD VARCHAR(500) DEFAULT ' ' NOT NULL,
    FENTRYTOTAL           INT          DEFAULT 0   NOT NULL,
    FFAILEDNUMBER         INT          DEFAULT 0   NOT NULL,
    FFAILEDREASON         NVARCHAR(255) DEFAULT ' ' NOT NULL,
    FFAILEDREASON_TAG     NCLOB,
    FENTITYIMPORTSTATUS   CHAR(1)      DEFAULT '0' NOT NULL
);

EXEC P_ALTERPK 'PK_T_BAS_MULIMP_RESULTTREE', 'T_BAS_MULIMP_RESULTTREE', 'FENTRYID', '1';

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