/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_constraint.sql **/
 EXEC p_DropIdx 'IDX_IM_OTHERINBILL_L_FID', 'T_IM_OTHERINBILL_L';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_L_FLID') CREATE INDEX IDX_IM_OTHERINBILL_L_FLID ON T_IM_OTHERINBILL_L ( FID ,FLOCALEID );

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ASSB_D_WH') CREATE INDEX IDX_IM_ASSB_D_WH ON T_IM_ASSEMBBILLSUBENTRY ( FWAREHOUSEID );

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

 EXEC p_DropIdx 'IDX_IM_DISASSEMBLE_L_LOCALE', 'T_IM_DISASSEMBLEBILL_L';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_DISASSEMBL_L_FLID') CREATE INDEX IDX_IM_DISASSEMBL_L_FLID ON T_IM_DISASSEMBLEBILL_L ( FID ,FLOCALEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_DISASSEMBLESUBEY_WH') CREATE INDEX IDX_IM_DISASSEMBLESUBEY_WH ON T_IM_DISASSEMBLESUBENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_E_FOW') CREATE INDEX IDX_IM_OTHERINBILL_E_FOW ON T_IM_OTHERINBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_E_WH') CREATE INDEX IDX_IM_OTHERINBILL_E_WH ON T_IM_OTHERINBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSAPPLY_E_WH') CREATE INDEX IDX_IM_TRANSAPPLY_E_WH ON T_IM_TRANSAPPLYENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MRBL_E_WH') CREATE INDEX IDX_IM_MRBL_E_WH ON T_IM_MREQBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MTB_E_FOOWID') CREATE INDEX IDX_IM_MTB_E_FOOWID ON T_IM_MREQOUTBILLENTRY ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MTB_E_WH') CREATE INDEX IDX_IM_MTB_E_WH ON T_IM_MREQOUTBILLENTRY ( FWAREHOUSEID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PRBL_E_WH') CREATE INDEX IDX_IM_PRBL_E_WH ON T_IM_PRODUCTINBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ADJ_E_FOWID') CREATE INDEX IDX_IM_ADJ_E_FOWID ON T_IM_ADJUSTBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ADJ_E_WH') CREATE INDEX IDX_IM_ADJ_E_WH ON T_IM_ADJUSTBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ASSB_E_FOWID') CREATE INDEX IDX_IM_ASSB_E_FOWID ON T_IM_ASSEMBBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ASSB_E_WH') CREATE INDEX IDX_IM_ASSB_E_WH ON T_IM_ASSEMBBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_LOCALTS_E_FOWID') CREATE INDEX IDX_IM_LOCALTS_E_FOWID ON T_IM_LOCATIONTRANSENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_LOCALTS_E_WH') CREATE INDEX IDX_IM_LOCALTS_E_WH ON T_IM_LOCATIONTRANSENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_DISASSEMBLEEY_OW') CREATE INDEX IDX_IM_DISASSEMBLEEY_OW ON T_IM_DISASSEMBLEENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_DISASSEMBLEEY_WH') CREATE INDEX IDX_IM_DISASSEMBLEEY_WH ON T_IM_DISASSEMBLEENTRY ( FWAREHOUSEID );

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PIBILLENTRY_R_SRCID') CREATE INDEX IDX_IM_PIBILLENTRY_R_SRCID ON T_IM_PURINBILLENTRY_R ( FSRCBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PIBILLENTRY_R_MAINID') CREATE INDEX IDX_IM_PIBILLENTRY_R_MAINID ON T_IM_PURINBILLENTRY_R ( FMAINBILLID );

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILLENTRY_R_SRCID') CREATE INDEX IDX_IM_SOBILLENTRY_R_SRCID ON T_IM_SALOUTBILLENTRY_R ( FSRCBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILLENTRY_R_MAINID') CREATE INDEX IDX_IM_SOBILLENTRY_R_MAINID ON T_IM_SALOUTBILLENTRY_R ( FMAINBILLID );

 EXEC p_DropIdx 'IDX_IM_ADJ_FBIZT', 'T_IM_ADJUSTBILL';
 EXEC p_DropIdx 'IDX_IM_ADJ_FBTID', 'T_IM_ADJUSTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ADJ_FBIZTORGNO') CREATE INDEX IDX_IM_ADJ_FBIZTORGNO ON T_IM_ADJUSTBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_ASSB_FBT', 'T_IM_ASSEMBBILL';
 EXEC p_DropIdx 'IDX_IM_ASSB_FBTP', 'T_IM_ASSEMBBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ASSB_FBIZTORGNO') CREATE INDEX IDX_IM_ASSB_FBIZTORGNO ON T_IM_ASSEMBBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_DISASSEMBL_BIZTIME', 'T_IM_DISASSEMBLEBILL';
 EXEC p_DropIdx 'IDX_IM_DISASSEMBL_BIZTYPE', 'T_IM_DISASSEMBLEBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_DISASSEMBL_BIZTORGNO') CREATE INDEX IDX_IM_DISASSEMBL_BIZTORGNO ON T_IM_DISASSEMBLEBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_IM_INITBILLENTRY_WH') CREATE INDEX IDX_T_IM_INITBILLENTRY_WH ON T_IM_INITBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSOUTBILL_E_X_OOW') CREATE INDEX IDX_IM_TRANSOUTBILL_E_X_OOW ON T_IM_TRANSOUTBILLENTRY_X ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIR_E_X_OOW') CREATE INDEX IDX_IM_TRANSDIR_E_X_OOW ON T_IM_TRANSDIRBILLENTRY_X ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PURRECBILL_E_D_OW') CREATE INDEX IDX_IM_PURRECBILL_E_D_OW ON T_IM_PURRECBILLENTRY_D ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PURRECBILL_E_D_WH') CREATE INDEX IDX_IM_PURRECBILL_E_D_WH ON T_IM_PURRECBILLENTRY_D ( FWAREHOUSEID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHEROUTBILL_E_OOW') CREATE INDEX IDX_IM_OTHEROUTBILL_E_OOW ON T_IM_OTHEROUTBILLENTRY ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHEROUTBILL_E_WH') CREATE INDEX IDX_IM_OTHEROUTBILL_E_WH ON T_IM_OTHEROUTBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSINBILL_E_OW') CREATE INDEX IDX_IM_TRANSINBILL_E_OW ON T_IM_TRANSINBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSINBILL_E_WH') CREATE INDEX IDX_IM_TRANSINBILL_E_WH ON T_IM_TRANSINBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSOUTBILL_E_WH') CREATE INDEX IDX_IM_TRANSOUTBILL_E_WH ON T_IM_TRANSOUTBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIRBILL_E_OW') CREATE INDEX IDX_IM_TRANSDIRBILL_E_OW ON T_IM_TRANSDIRBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIRBILL_E_WH') CREATE INDEX IDX_IM_TRANSDIRBILL_E_WH ON T_IM_TRANSDIRBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INVCOUNTBILLENTRY_WH') CREATE INDEX IDX_IM_INVCOUNTBILLENTRY_WH ON T_IM_INVCOUNTBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILL_E_OW') CREATE INDEX IDX_IM_SOBILL_E_OW ON T_IM_SALOUTBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILL_E_OOW') CREATE INDEX IDX_IM_SOBILL_E_OOW ON T_IM_SALOUTBILLENTRY ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILL_E_WH') CREATE INDEX IDX_IM_SOBILL_E_WH ON T_IM_SALOUTBILLENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_E_OW') CREATE INDEX IDX_IM_PBILL_E_OW ON T_IM_PURINBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_E_OOW') CREATE INDEX IDX_IM_PBILL_E_OOW ON T_IM_PURINBILLENTRY ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_E_WH') CREATE INDEX IDX_IM_PBILL_E_WH ON T_IM_PURINBILLENTRY ( FWAREHOUSEID );

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ADJ_D_WH') CREATE INDEX IDX_IM_ADJ_D_WH ON T_IM_ADJUSTBILLSUBENTRY ( FWAREHOUSEID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSAPPLY_ORG') CREATE INDEX IDX_IM_TRANSAPPLY_ORG ON T_IM_TRANSAPPLY ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSAPPLY_BIZTORGNO') CREATE INDEX IDX_IM_TRANSAPPLY_BIZTORGNO ON T_IM_TRANSAPPLY ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INVCOUNTBILL_ORG') CREATE INDEX IDX_IM_INVCOUNTBILL_ORG ON T_IM_INVCOUNTBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INVCOUNTBILL_BIZTORGNO') CREATE INDEX IDX_IM_INVCOUNTBILL_BIZTORGNO ON T_IM_INVCOUNTBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INITBILL_ORG') CREATE INDEX IDX_IM_INITBILL_ORG ON T_IM_INITBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_INITBILL_BIZTORGNO') CREATE INDEX IDX_IM_INITBILL_BIZTORGNO ON T_IM_INITBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_PRBL_IDTN', 'T_IM_PRODUCTINBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PRBL_ORG') CREATE INDEX IDX_IM_PRBL_ORG ON T_IM_PRODUCTINBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PRBL_BIZTORGNO') CREATE INDEX IDX_IM_PRBL_BIZTORGNO ON T_IM_PRODUCTINBILL ( FBIZTIMES  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_TRANSOUTBILL', 'T_IM_TRANSOUTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSOUTBILL_ORG') CREATE INDEX IDX_IM_TRANSOUTBILL_ORG ON T_IM_TRANSOUTBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSOUTBILL_BIZTORGNO') CREATE INDEX IDX_IM_TRANSOUTBILL_BIZTORGNO ON T_IM_TRANSOUTBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSOUTBILL_IORG') CREATE INDEX IDX_IM_TRANSOUTBILL_IORG ON T_IM_TRANSOUTBILL ( FINORGID );

 EXEC p_DropIdx 'IDX_IM_TRANSINBILL', 'T_IM_TRANSINBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSINBILL_ORG') CREATE INDEX IDX_IM_TRANSINBILL_ORG ON T_IM_TRANSINBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSINBILL_BIZTORGNO') CREATE INDEX IDX_IM_TRANSINBILL_BIZTORGNO ON T_IM_TRANSINBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSINBILL_OORG') CREATE INDEX IDX_IM_TRANSINBILL_OORG ON T_IM_TRANSINBILL ( FOUTORGID );

 EXEC p_DropIdx 'IDX_IM_MREQOUTB_BILLTYPEID', 'T_IM_MREQOUTBILL';
 EXEC p_DropIdx 'IDX_IM_MREQOUTBBL_BIZTIME', 'T_IM_MREQOUTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MREQOUTB_BIZTORGNO') CREATE INDEX IDX_IM_MREQOUTB_BIZTORGNO ON T_IM_MREQOUTBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_MREQOUTB_BIZORG') CREATE INDEX IDX_IM_MREQOUTB_BIZORG ON T_IM_MREQOUTBILL ( FBIZORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIRBILL_ORG') CREATE INDEX IDX_IM_TRANSDIRBILL_ORG ON T_IM_TRANSDIRBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIRBILL_BIZTORGNO') CREATE INDEX IDX_IM_TRANSDIRBILL_BIZTORGNO ON T_IM_TRANSDIRBILL ( FBIZTIME  DESC ,FOUTORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_TRANSDIRBILL_OORG') CREATE INDEX IDX_IM_TRANSDIRBILL_OORG ON T_IM_TRANSDIRBILL ( FOUTORGID );

 EXEC p_DropIdx 'IDX_IM_OTHEROUTBILL_IDTN', 'T_IM_OTHEROUTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHEROUTBILL_ORG') CREATE INDEX IDX_IM_OTHEROUTBILL_ORG ON T_IM_OTHEROUTBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHEROUTBILL_BIZTORGNO') CREATE INDEX IDX_IM_OTHEROUTBILL_BIZTORGNO ON T_IM_OTHEROUTBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHEROUTBILL_CUSTM') CREATE INDEX IDX_IM_OTHEROUTBILL_CUSTM ON T_IM_OTHEROUTBILL ( FCUSTOMERID );

 EXEC p_DropIdx 'IDX_IM_OTHERINBILL_IDTN', 'T_IM_OTHERINBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_ORG') CREATE INDEX IDX_IM_OTHERINBILL_ORG ON T_IM_OTHERINBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_BIZTORGNO') CREATE INDEX IDX_IM_OTHERINBILL_BIZTORGNO ON T_IM_OTHERINBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OTHERINBILL_SUPPL') CREATE INDEX IDX_IM_OTHERINBILL_SUPPL ON T_IM_OTHERINBILL ( FSUPPLIERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_LOCALTS_ORG') CREATE INDEX IDX_IM_LOCALTS_ORG ON T_IM_LOCATIONTRANSFER ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_LOCALTS_BIZTORGNO') CREATE INDEX IDX_IM_LOCALTS_BIZTORGNO ON T_IM_LOCATIONTRANSFER ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

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

 EXEC p_DropIdx 'IDX_IM_PURRECBILL_IDTN', 'T_IM_PURRECBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PURRECBILL_ORG') CREATE INDEX IDX_IM_PURRECBILL_ORG ON T_IM_PURRECBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PURRECBILL_BIZTORGNO') CREATE INDEX IDX_IM_PURRECBILL_BIZTORGNO ON T_IM_PURRECBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_PBILL_FORFBIZFNO', 'T_IM_PURINBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_ORG') CREATE INDEX IDX_IM_PBILL_ORG ON T_IM_PURINBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_PBILL_BIZTORGNO') CREATE INDEX IDX_IM_PBILL_BIZTORGNO ON T_IM_PURINBILL ( FBIZTIME  DESC ,FORGID ,FBILLNO  DESC );

 EXEC p_DropIdx 'IDX_IM_SOBILL_FORFBIZFNO', 'T_IM_SALOUTBILL';
 EXEC p_DropIdx 'IDX_IM_SALEOUTBL_BIZTIME', 'T_IM_SALOUTBILL';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_SOBILL_ORG') CREATE INDEX IDX_IM_SOBILL_ORG ON T_IM_SALOUTBILL ( FORGID );

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


/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_constraint.sql **/
