/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_IM_OSMREQOUTBILL', 'T_IM_OSMREQOUTBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OSMRBILL_BKTORGNO') CREATE INDEX IDX_IM_OSMRBILL_BKTORGNO ON T_IM_OSMREQOUTBILL ( FBOOKDATE ,FORGID ,FBILLNO );

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

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OSMRB_INVSCHEME') CREATE INDEX IDX_IM_OSMRB_INVSCHEME ON T_IM_OSMREQOUTBILL ( FINVSCHEMEID );


 EXEC P_ALTERPK 'PK_T_IM_OSMREQOUTBILL_L', 'T_IM_OSMREQOUTBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_IM_OSMREQOUTBILLENTRY', 'T_IM_OSMREQOUTBILLENTRY', 'FENTRYID', '1';

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

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

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

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

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


 EXEC P_ALTERPK 'PK_T_IM_OSMREQOUTBILLENTRY_R', 'T_IM_OSMREQOUTBILLENTRY_R', 'FENTRYID', '1';

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

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

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


 EXEC P_ALTERPK 'PK_T_IM_OSPURINBILL', 'T_IM_OSPURINBILL', 'FID', '1';

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

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OSPBILL_BKTORGNO') CREATE INDEX IDX_IM_OSPBILL_BKTORGNO ON T_IM_OSPURINBILL ( FBOOKDATE ,FORGID ,FBILLNO );


 EXEC P_ALTERPK 'PK_T_IM_OSPURINBILL_L', 'T_IM_OSPURINBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_IM_OSPURINBILLENTRY', 'T_IM_OSPURINBILLENTRY', 'FENTRYID', '1';

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

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

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

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

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


 EXEC P_ALTERPK 'PK_T_IM_OSPURINBILLENTRY_L', 'T_IM_OSPURINBILLENTRY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_OSPURINBILLENTRY_L_ID') CREATE INDEX IDX_IM_OSPURINBILLENTRY_L_ID ON T_IM_OSPURINBILLENTRY_L ( FENTRYID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_IM_OSPURINBILLENTRY_R', 'T_IM_OSPURINBILLENTRY_R', 'FENTRYID', '1';

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

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

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

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

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



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