IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_HISTORYENTRYMULWAYTO')
 CREATE TABLE T_ER_HISTORYENTRYMULWAYTO (
FPKID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL
);

EXEC P_ALTERPK 'PK_T_ER_HISTORYENTRYMULWAYTO', 'T_ER_HISTORYENTRYMULWAYTO', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_HISTORYENTRYMULWAYTO_ENTRYID') CREATE UNIQUE INDEX IDX_ER_HISTORYENTRYMULWAYTO_ENTRYID ON T_ER_HISTORYENTRYMULWAYTO ( FENTRYID ,FBASEDATAID );


