/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_constraint.sql **/
 EXEC P_ALTERPK 'PK_IM_OTHEROUTBILLENTRY_F', 'T_IM_OTHEROUTBILLENTRY_F', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_IM_PRODUCTINBILL', 'T_IM_PRODUCTINBILL', 'FID', '1';

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

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


 EXEC P_ALTERPK 'PK_IM_PRODUCTINBILLENTRY', 'T_IM_PRODUCTINBILLENTRY', 'FENTRYID', '1';

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

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

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

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

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


 EXEC P_ALTERPK 'PK_IM_INVBILLSNENTRY', 'T_IM_INVBILLSNENTRY', 'FDETAILID', '1';

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


 EXEC P_ALTERPK 'PK_IM_MREQOUTBILL', 'T_IM_MREQOUTBILL', 'FID', '1';

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

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

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


 EXEC P_ALTERPK 'PK_IM_MREQOUTBILLENTRY', 'T_IM_MREQOUTBILLENTRY', 'FENTRYID', '1';

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

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

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


 EXEC P_ALTERPK 'PK_IM_MREQOUTBILLENTRY_R', 'T_IM_MREQOUTBILLENTRY_R', 'FENTRYID', '1';

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

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


 EXEC P_ALTERPK 'PK_IM_PRODUCTINBILLENTRY_R', 'T_IM_PRODUCTINBILLENTRY_R', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_IM_PRODUCTINBILLENTRY_X', 'T_IM_PRODUCTINBILLENTRY_X', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_IM_PRODUCTINBILL_L', 'T_IM_PRODUCTINBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_IM_MREQOUTBILLSNENTRY', 'T_IM_MREQOUTBILLSNENTRY', 'FDETAILID', '1';

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

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



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