/**Begin D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_constraint.sql **/
 EXEC P_ALTERPK 'PK_IM_BIZTYPEENTRY', 'T_IM_BIZTYPEENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_BT_E_FID') CREATE INDEX IDX_IM_BT_E_FID ON T_IM_BIZTYPEENTRY ( FID );


 EXEC P_ALTERPK 'PK_IM_INTERORGSETTLECFG', 'T_IM_INTERORGSETTLECFG', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_IM_INVTYPEENTRY', 'T_IM_INVTYPEENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INTT_E_FID') CREATE INDEX IDX_IM_INTT_E_FID ON T_IM_INVTYPEENTRY ( FID );


 EXEC P_ALTERPK 'PK_IM_OUTINVTYPEENTRY', 'T_IM_OUTINVTYPEENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OUTT_E_FID') CREATE INDEX IDX_IM_OUTT_E_FID ON T_IM_OUTINVTYPEENTRY ( FID );


 EXEC P_ALTERPK 'PK_IM_SETTLERELATIONS_L', 'T_IM_SETTLERELATIONS_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SETLT_L_FLID') CREATE INDEX IDX_IM_SETLT_L_FLID ON T_IM_SETTLERELATIONS_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_IM_SETTLERELATIONDETAIL', 'T_IM_SETTLERELATIONDETAIL', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SETTLD_FSP') CREATE INDEX IDX_IM_SETTLD_FSP ON T_IM_SETTLERELATIONDETAIL ( FSUPPLIER );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SETTLD_FDE') CREATE INDEX IDX_IM_SETTLD_FDE ON T_IM_SETTLERELATIONDETAIL ( FDEMAND );


 EXEC P_ALTERPK 'PK_IM_SETTLERELATIONS', 'T_IM_SETTLERELATIONS', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SETLT_FSORG') CREATE INDEX IDX_IM_SETLT_FSORG ON T_IM_SETTLERELATIONS ( FSETTLEORG );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SETLT_FOWN') CREATE INDEX IDX_IM_SETLT_FOWN ON T_IM_SETTLERELATIONS ( FOWNER );


 EXEC P_ALTERPK 'PK_IM_INVENTORY_L', 'T_IM_INVENTORY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INV_L') CREATE INDEX IDX_IM_INV_L ON T_IM_INVENTORY_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_IM_INTERORGPRICE', 'T_IM_INTERORGPRICE', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INT_OP_FCT') CREATE INDEX IDX_IM_INT_OP_FCT ON T_IM_INTERORGPRICE ( FCREATETIME  DESC );


 EXEC P_ALTERPK 'PK_IM_INTERORGPRICE_L', 'T_IM_INTERORGPRICE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INT_OP_L_FLID') CREATE INDEX IDX_IM_INT_OP_L_FLID ON T_IM_INTERORGPRICE_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_IM_INTERORGPRICEINFO', 'T_IM_INTERORGPRICEINFO', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INT_OPE_FID') CREATE INDEX IDX_IM_INT_OPE_FID ON T_IM_INTERORGPRICEINFO ( FID );


 EXEC P_ALTERPK 'PK_IM_INVENTORY', 'T_IM_INVENTORY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_IV_FGP') CREATE INDEX IDX_IM_IV_FGP ON T_IM_INVENTORY ( FGROUPID );

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



/**End D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_constraint.sql **/
