/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_AR_SALOUTWFRECORD', 'T_AR_SALOUTWFRECORD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_SALOUTWFRECORD' AND KSQL_INDNAME = 'IDX_AR_SALWF_FNUMBER') CREATE INDEX IDX_AR_SALWF_FNUMBER ON T_AR_SALOUTWFRECORD ( FWFNUMBER );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_SALOUTWFRECORD' AND KSQL_INDNAME = 'IDX_AR_SALWF_ORG_DATE') CREATE INDEX IDX_AR_SALWF_ORG_DATE ON T_AR_SALOUTWFRECORD ( FORGID ,FCREATETIME );


 EXEC P_ALTERPK 'PK_T_AR_ORIGINALWFRECORD', 'T_AR_ORIGINALWFRECORD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_ORIGINALWFRECORD' AND KSQL_INDNAME = 'IDX_AR_ORIGINAL_FNUMBER') CREATE INDEX IDX_AR_ORIGINAL_FNUMBER ON T_AR_ORIGINALWFRECORD ( FWFNUMBER );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_ORIGINALWFRECORD' AND KSQL_INDNAME = 'IDX_AR_ORIGINAL_DATE_ORG') CREATE INDEX IDX_AR_ORIGINAL_DATE_ORG ON T_AR_ORIGINALWFRECORD ( FCREATETIME ,FORGID );


 EXEC P_ALTERPK 'PK_T_AR_ORIGINALWFENTRY', 'T_AR_ORIGINALWFENTRY', 'FENTRYID', '1';

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

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_ORIGINALWFENTRY' AND KSQL_INDNAME = 'IDX_AR_ORIGINALE_FASSBILLID') CREATE INDEX IDX_AR_ORIGINALE_FASSBILLID ON T_AR_ORIGINALWFENTRY ( FASSBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_ORIGINALWFENTRY' AND KSQL_INDNAME = 'IDX_AR_ORIGINALE_FASSENTRYID') CREATE INDEX IDX_AR_ORIGINALE_FASSENTRYID ON T_AR_ORIGINALWFENTRY ( FASSBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_ORIGINALWFENTRY' AND KSQL_INDNAME = 'IDX_AR_ORIGINALE_FASSBILLNO') CREATE INDEX IDX_AR_ORIGINALE_FASSBILLNO ON T_AR_ORIGINALWFENTRY ( FASSBILLNO );


 EXEC P_ALTERPK 'PK_T_AR_SALOUTWFRECORDENTRY', 'T_AR_SALOUTWFRECORDENTRY', 'FENTRYID', '1';

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

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

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_SALOUTWFRECORDENTRY' AND KSQL_INDNAME = 'IDX_AR_SALWFE_FASSBILLID') CREATE INDEX IDX_AR_SALWFE_FASSBILLID ON T_AR_SALOUTWFRECORDENTRY ( FASSBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_SALOUTWFRECORDENTRY' AND KSQL_INDNAME = 'IDX_AR_SALWFE_FASSBILLENTRYID') CREATE INDEX IDX_AR_SALWFE_FASSBILLENTRYID ON T_AR_SALOUTWFRECORDENTRY ( FASSBILLENTRYID );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_AR_SALOUTWFRECORDENTRY' AND KSQL_INDNAME = 'IDX_AR_SALWFE_FASSBILLNO') CREATE INDEX IDX_AR_SALWFE_FASSBILLNO ON T_AR_SALOUTWFRECORDENTRY ( FASSBILLNO );



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