EXEC P_ALTERPK 'PK_MSPLAN_LINERULES', 'T_MSPLAN_LINERULES', 'FID', '1';

EXEC P_ALTERPK 'PK_MSPLAN_LINERULES_L', 'T_MSPLAN_LINERULES_L', 'FPKID', '1'; 

EXEC P_ALTERPK 'PK_MSPLAN_LINEMATERIAL', 'T_MSPLAN_LINEMATERIAL', 'FENTRYID', '1';

EXEC P_ALTERPK 'PK_MSPLAN_LINEWORK', 'T_MSPLAN_LINEWORK', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MSPLAN_LINERULES_NUMBER') CREATE INDEX IDX_MSPLAN_LINERULES_NUMBER ON T_MSPLAN_LINERULES ( FNUMBER );

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MSPLAN_LINEMATERIAL') CREATE INDEX IDX_MSPLAN_LINEMATERIAL ON T_MSPLAN_LINEMATERIAL ( FID ,FSEQ );

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MSPLAN_LINEWORK') CREATE INDEX IDX_MSPLAN_LINEWORK ON T_MSPLAN_LINEWORK ( FID ,FSEQ );
