/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_constraint.sql **/
 EXEC P_ALTERPK 'PK_IM_ASSEMBBILL_L', 'T_IM_ASSEMBBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_IM_ASSEMBBILLSUBENTRY', 'T_IM_ASSEMBBILLSUBENTRY', 'FDETAILID', '1';

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

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


 EXEC P_ALTERPK 'PK_IM_ASSEMBBILLENTRY', 'T_IM_ASSEMBBILLENTRY', 'FENTRYID', '1';

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

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


 EXEC P_ALTERPK 'PK_IM_ASSEMBBILL', 'T_IM_ASSEMBBILL', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IM_ASSB_FBT') CREATE INDEX IDX_IM_ASSB_FBT ON T_IM_ASSEMBBILL ( FBIZTIME  DESC );

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

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



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