diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index ddbe5049dd..11447fb4c0 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -1768,6 +1768,47 @@ public final class DB return retValue; } // getKeyNamePairs + /** + * Get Array of IDs + * @param trxName + * @param sql select with id as first column + * @param params query parameters + * @throws DBException if there is any SQLException + */ + public static int[] getIDsEx(String trxName, String sql, Object ... params) throws DBException + { + PreparedStatement pstmt = null; + ResultSet rs = null; + ArrayList list = new ArrayList(); + try + { + pstmt = DB.prepareStatement(sql, trxName); + setParameters(pstmt, params); + rs = pstmt.executeQuery(); + while (rs.next()) + { + list.add(rs.getInt(1)); + } + } + catch (SQLException e) + { + throw new DBException(e, sql); + } + finally + { + close(rs, pstmt); + rs= null; + pstmt = null; + } + // Convert to array + int[] retValue = new int[list.size()]; + for (int i = 0; i < retValue.length; i++) + { + retValue[i] = list.get(i); + } + return retValue; + } // getIDsEx + /** * Is Sales Order Trx. * Assumes Sales Order. Queries IsSOTrx of table with where clause @@ -2395,4 +2436,3 @@ public final class DB } } // DB -