IF
NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_ATTACHMENT_OPLOG_L')
CREATE TABLE T_BAS_ATTACHMENT_OPLOG_L
(
    FPKID        VARCHAR(36)  DEFAULT ' ' NOT NULL,
    FID          BIGINT       DEFAULT 0   NOT NULL,
    FLOCALEID    VARCHAR(10)  DEFAULT ' ' NOT NULL,
    FDESCRIPTION VARCHAR(500) DEFAULT ' ' NOT NULL
);

EXEC p_AlterPK 'pk_bas_attachment_oplog_l', 'T_BAS_ATTACHMENT_OPLOG_L', 'fpkid', '1';
 IF
NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_BAS_ATTACHMENT_OPLOG_L' AND KSQL_INDNAME = 'IDX_BAS_ATTACHMENT_OPLOG_L_0')
 CREATE
INDEX IDX_BAS_ATTACHMENT_OPLOG_L_0 ON T_BAS_ATTACHMENT_OPLOG_L (FID ,FLOCALEID );
