IF
NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_MULIMP_RES_SUBTREE')
CREATE TABLE T_BAS_MULIMP_RES_SUBTREE
(
    FENTRYID        BIGINT DEFAULT 0 NOT NULL,
    FDETAILID       BIGINT DEFAULT 0 NOT NULL,
    FSEQ            INT    DEFAULT 0 NOT NULL,
    FROW            INT    DEFAULT 0 NOT NULL,
    FFAILREASON     NVARCHAR(100) DEFAULT ' ' NOT NULL,
    FFAILREASON_TAG NCLOB
);



EXEC P_ALTERPK 'PK_T_BAS_MULIMP_RES_SUBTREE', 'T_BAS_MULIMP_RES_SUBTREE', 'FDETAILID', '1';

 IF
NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BAS_MULIMP_RES_SUBTREE_FK') CREATE
INDEX IDX_BAS_MULIMP_RES_SUBTREE_FK ON T_BAS_MULIMP_RES_SUBTREE ( FENTRYID );



