/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AP_constraint.sql **/

 EXEC P_ALTERPK 'PK_T_AP_MATCHMAPPING', 'T_AP_MATCHMAPPING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_MATCHMAPPING' AND KSQL_INDNAME = 'INDEX_AP_MMP_NUMBER') CREATE INDEX INDEX_AP_MMP_NUMBER ON T_AP_MATCHMAPPING ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AP_MATCHMAPPING_E', 'T_AP_MATCHMAPPING_E', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_AP_MATCHMAPPING_L', 'T_AP_MATCHMAPPING_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AP_MATCHRELATION', 'T_AP_MATCHRELATION', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_MATCHRELATION' AND KSQL_INDNAME = 'IDX_AP_MR_NUMBER') CREATE INDEX IDX_AP_MR_NUMBER ON T_AP_MATCHRELATION ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AP_MATCHRELATION_E', 'T_AP_MATCHRELATION_E', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_AP_MATCHRELATION_L', 'T_AP_MATCHRELATION_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2', 'T_AP_MATCHSCHEMEV2', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_MATCHSCHEMEV2' AND KSQL_INDNAME = 'IDX_AP_MSV2_NUMBER') CREATE INDEX IDX_AP_MSV2_NUMBER ON T_AP_MATCHSCHEMEV2 ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2_ALGO', 'T_AP_MATCHSCHEMEV2_ALGO', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2_ALGO_L', 'T_AP_MATCHSCHEMEV2_ALGO_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_MATCHSCHEMEV2_ALGO_L' AND KSQL_INDNAME = 'IDX_AP_MSALGOL_FENTRYID') CREATE INDEX IDX_AP_MSALGOL_FENTRYID ON T_AP_MATCHSCHEMEV2_ALGO_L ( FENTRYID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2_C', 'T_AP_MATCHSCHEMEV2_C', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_MATCHSCHEMEV2_C' AND KSQL_INDNAME = 'IDX_MSC_FDETAILID') CREATE INDEX IDX_MSC_FDETAILID ON T_AP_MATCHSCHEMEV2_C ( FENTRYID );


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2_L', 'T_AP_MATCHSCHEMEV2_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AP_MATCHSCHEMEV2_O', 'T_AP_MATCHSCHEMEV2_O', 'FENTRYID', '1';

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

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

/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AP_constraint.sql **/

 EXEC P_ALTERPK 'PK_T_AP_INVMATCH', 'T_AP_INVMATCH', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCH' AND KSQL_INDNAME = 'IDX_AP_IM_MATCHDATE') CREATE INDEX IDX_AP_IM_MATCHDATE ON T_AP_INVMATCH ( FMATCHDATE );

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


 EXEC P_ALTERPK 'PK_T_AP_INVMATCHIENTRY', 'T_AP_INVMATCHIENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHIENTRY' AND KSQL_INDNAME = 'IDX_AP_IMIE_IDENTRYID') CREATE INDEX IDX_AP_IMIE_IDENTRYID ON T_AP_INVMATCHIENTRY ( FINVOICEID ,FINVOICEENTRYID );


 EXEC P_ALTERPK 'PK_T_AP_INVMATCHOBJAENTRY', 'T_AP_INVMATCHOBJAENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJAENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOAE_FBILLID') CREATE INDEX IDX_AP_IMOAE_FBILLID ON T_AP_INVMATCHOBJAENTRY ( FBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJAENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOAE_FBILLENTRY') CREATE INDEX IDX_AP_IMOAE_FBILLENTRY ON T_AP_INVMATCHOBJAENTRY ( FBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJAENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOAE_FINAPID') CREATE INDEX IDX_AP_IMOAE_FINAPID ON T_AP_INVMATCHOBJAENTRY ( FFINAPBILLID );


 EXEC P_ALTERPK 'PK_T_AP_INVMATCHOBJBENTRY', 'T_AP_INVMATCHOBJBENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJBENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOBE_FBILLID') CREATE INDEX IDX_AP_IMOBE_FBILLID ON T_AP_INVMATCHOBJBENTRY ( FBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJBENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOBE_FBILLENTRYID') CREATE INDEX IDX_AP_IMOBE_FBILLENTRYID ON T_AP_INVMATCHOBJBENTRY ( FBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJBENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOBE_FINID') CREATE INDEX IDX_AP_IMOBE_FINID ON T_AP_INVMATCHOBJBENTRY ( FFINAPBILLID );


 EXEC P_ALTERPK 'PK_T_AP_INVMATCHOBJCENTRY', 'T_AP_INVMATCHOBJCENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJCENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOCE_FBILLID') CREATE INDEX IDX_AP_IMOCE_FBILLID ON T_AP_INVMATCHOBJCENTRY ( FBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AP_INVMATCHOBJCENTRY' AND KSQL_INDNAME = 'IDX_AP_IMOCE_FBILLENTRYID') CREATE INDEX IDX_AP_IMOCE_FBILLENTRYID ON T_AP_INVMATCHOBJCENTRY ( FBILLENTRYID );

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