Hi,

I thought of using batch update but then I would have to handle batch size
( not sure what batch size to use ). Also this being a one time migration,
I thought it would not be a significant improvement.

Thanks,


On Sat, Dec 21, 2013 at 12:30 AM, wluyima <notifications@github.com> wrote:

> In
> api/src/main/java/org/openmrs/util/databasechange/MigrateDrugOrderUnitsToCodedDoseUnitsChangeset.java:
>
> > +            throw new CustomChangeException(e);
> > +        }
> > +    }
> > +
> > +    private void migrateUnitsToCodedValue(JdbcConnection connection, List<String> uniqueUnits) throws CustomChangeException, SQLException, DatabaseException {
> > +        PreparedStatement updateDrugOrderStatement = null;
> > +        Boolean autoCommit = null;
> > +        try {
> > +            autoCommit = connection.getAutoCommit();
> > +            connection.setAutoCommit(false);
> > +            updateDrugOrderStatement = connection.prepareStatement("update drug_order set dose_units = ? where units = ?");
> > +            for (String unit : uniqueUnits) {
> > +                Integer conceptIdForUnit = DatabaseUtil.getConceptIdForUnits(connection.getUnderlyingConnection(), unit);
> > +                updateDrugOrderStatement.setInt(1, conceptIdForUnit);
> > +                updateDrugOrderStatement.setString(2, unit);
> > +                updateDrugOrderStatement.executeUpdate();
>
> I would just use batch update here instead by just calling
> updateDrugOrderStatement.addBatch() and then before line 49 below i call
> updateDrugOrderStatement.executeBatch()
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/openmrs/openmrs-core/pull/488/files#r8507484>
> .
>