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

 EXEC P_ALTERPK 'PK_T_ER_BILLINGTYPE_REL', 'T_ER_BILLINGTYPE_REL', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_BILLING_REL') CREATE INDEX IDX_ER_BILLING_REL ON T_ER_BILLINGTYPE_REL ( FBASEDATAID );
