/**Begin D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_constraint.sql **/
EXEC p_DropIdx 'IDX_IM_PurInBill_Number', 'T_IM_PURINBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_FORFBIZFNO') CREATE INDEX IDX_IM_PBILL_FORFBIZFNO ON T_IM_PURINBILL ( FORGID ,FBIZTIME  DESC ,FBILLNO  DESC );

EXEC p_DropIdx 'IDX_IM_SalOutBill_Number', 'T_IM_SALOUTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILL_FORFBIZFNO') CREATE INDEX IDX_IM_SOBILL_FORFBIZFNO ON T_IM_SALOUTBILL ( FORGID ,FBIZTIME  DESC ,FBILLNO  DESC );

 EXEC P_ALTERPK 'PK_IM_MDC_MFTREQOUTBILL', 'T_IM_MDC_MFTREQOUTBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MQBL_FNO') CREATE INDEX IDX_IM_MDC_MQBL_FNO ON T_IM_MDC_MFTREQOUTBILL ( FBILLNO );


 EXEC P_ALTERPK 'PK_IM_MDC_MFTREQOUTBILL_L', 'T_IM_MDC_MFTREQOUTBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_IM_MDC_MFTREQOUTENTRY', 'T_IM_MDC_MFTREQOUTENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MFQ_E_FMID') CREATE INDEX IDX_IM_MDC_MFQ_E_FMID ON T_IM_MDC_MFTREQOUTENTRY ( FMATERIALID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MFQ_E_FMMID') CREATE INDEX IDX_IM_MDC_MFQ_E_FMMID ON T_IM_MDC_MFTREQOUTENTRY ( FMATERIALMASTERID );


 EXEC P_ALTERPK 'PK_IM_MDC_MFTREQOUTENTRY_R', 'T_IM_MDC_MFTREQOUTENTRY_R', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MQE_R_FSID') CREATE INDEX IDX_IM_MDC_MQE_R_FSID ON T_IM_MDC_MFTREQOUTENTRY_R ( FSRCBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MQE_R_FMEID') CREATE INDEX IDX_IM_MDC_MQE_R_FMEID ON T_IM_MDC_MFTREQOUTENTRY_R ( FMAINBILLENTRYID );


 EXEC P_ALTERPK 'PK_IM_MDC_MREQOUTSNENTRY', 'T_IM_MDC_MREQOUTSNENTRY', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MQ_D_FEID') CREATE INDEX IDX_IM_MDC_MQ_D_FEID ON T_IM_MDC_MREQOUTSNENTRY ( FENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MDC_MQ_D_FSID') CREATE INDEX IDX_IM_MDC_MQ_D_FSID ON T_IM_MDC_MREQOUTSNENTRY ( FSERIALID );



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