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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL' AND KSQL_INDNAME = 'IDX_IM_INSPB_BKTORGNO') CREATE INDEX IDX_IM_INSPB_BKTORGNO ON T_IM_INVINSPECTBILL ( FBOOKDATE ,FORGID ,FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL' AND KSQL_INDNAME = 'IDX_IM_INSPB_FNO') CREATE INDEX IDX_IM_INSPB_FNO ON T_IM_INVINSPECTBILL ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL' AND KSQL_INDNAME = 'IDX_IM_INSPB_FORGID') CREATE INDEX IDX_IM_INSPB_FORGID ON T_IM_INVINSPECTBILL ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL' AND KSQL_INDNAME = 'IDX_IM_INSPB_BIZTORGNO') CREATE INDEX IDX_IM_INSPB_BIZTORGNO ON T_IM_INVINSPECTBILL ( FBIZTIME ,FORGID ,FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL' AND KSQL_INDNAME = 'IDX_IM_INSPB_INVSCHEME') CREATE INDEX IDX_IM_INSPB_INVSCHEME ON T_IM_INVINSPECTBILL ( FINVSCHEMEID );


 EXEC P_ALTERPK 'PK_T_IM_INVINSPECTBILL_L', 'T_IM_INVINSPECTBILL_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL_L' AND KSQL_INDNAME = 'IDX_IM_INSPB_L_ID') CREATE INDEX IDX_IM_INSPB_L_ID ON T_IM_INVINSPECTBILL_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_IM_INVINSPECTBILLENTRY', 'T_IM_INVINSPECTBILLENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_MMT') CREATE INDEX IDX_IM_INSPBILL_E_MMT ON T_IM_INVINSPECTBILLENTRY ( FMATERIALMASTERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_OOW') CREATE INDEX IDX_IM_INSPBILL_E_OOW ON T_IM_INVINSPECTBILLENTRY ( FOUTOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_OW') CREATE INDEX IDX_IM_INSPBILL_E_OW ON T_IM_INVINSPECTBILLENTRY ( FOWNERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_WH') CREATE INDEX IDX_IM_INSPBILL_E_WH ON T_IM_INVINSPECTBILLENTRY ( FWAREHOUSEID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_BILLID') CREATE INDEX IDX_IM_INSPBILL_E_BILLID ON T_IM_INVINSPECTBILLENTRY ( FID );


 EXEC P_ALTERPK 'PK_T_IM_INVINSPECTBILLENTRY_R', 'T_IM_INVINSPECTBILLENTRY_R', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY_R' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_E_R') CREATE INDEX IDX_IM_INSPBILL_E_R ON T_IM_INVINSPECTBILLENTRY_R ( FID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY_R' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_SRCEID') CREATE INDEX IDX_IM_INSPBILL_SRCEID ON T_IM_INVINSPECTBILLENTRY_R ( FSRCBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY_R' AND KSQL_INDNAME = 'IDX_IM_INSPBILL_SRCID') CREATE INDEX IDX_IM_INSPBILL_SRCID ON T_IM_INVINSPECTBILLENTRY_R ( FSRCBILLID );


 EXEC P_ALTERPK 'PK_T_IM_TAILADJUST_SETTING', 'T_IM_TAILADJUST_SETTING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_TAILADJUST_SETTING' AND KSQL_INDNAME = 'IDX_TAILADJUST_SETTING_FCOM') CREATE INDEX IDX_TAILADJUST_SETTING_FCOM ON T_IM_TAILADJUST_SETTING ( FCOMMONMAPID );



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