public static int selectMinInt(DbConnection conn, String tblName, String colName, String qual) throws Exception { int val = 0; DbSelectStatement stmt = null; String stmtText; try { stmt = new DbSelectStatement(); if (qual == null) stmtText = "SELECT MIN(" + colName + ") AS " + colName + " FROM " + tblName; else stmtText = "SELECT MIN(" + colName + ") AS " + colName + " FROM " + tblName + " " + qual; stmt.create(conn, stmtText); stmt.execute(); if (stmt.next()) { val = stmt.getShortInteger(1); stmt.release(); } stmt.release(); if (val == DbDataType.NULL_SHORT_INTEGER) val = 0; return val; } catch (Exception e) { DbSelectStatement.ensureRelease(stmt, e); throw e; } }
public static void select( DbConnection conn, String tblName, String colName, String qual, boolean distinct, IeciTdShortIntegerArrayList vals) throws Exception { DbSelectStatement stmt = null; try { stmt = new DbSelectStatement(); /* String sql = */ stmt.create(conn, tblName, colName, qual, distinct); stmt.execute(); while (stmt.next()) { vals.add(stmt.getShortInteger(1)); } stmt.release(); } catch (Exception e) { DbSelectStatement.ensureRelease(stmt, e); } }
public static short selectShortInteger( DbConnection conn, String tblName, String colName, String qual) throws Exception { short val = DbDataType.NULL_SHORT_INTEGER; DbSelectStatement stmt = null; try { stmt = new DbSelectStatement(); /* String sql = */ stmt.create(conn, tblName, colName, qual, false); stmt.execute(); if (stmt.next()) { val = stmt.getShortInteger(1); stmt.release(); return val; } else throw new IeciTdException(DbError.EC_NOT_FOUND, DbError.EM_NOT_FOUND); } catch (Exception e) { DbSelectStatement.ensureRelease(stmt, e); throw e; } }
public static int selectMaxInt( DbConnection conn, String tblName, String colName, String alias, String qual) throws Exception { int val = 0; DbSelectStatement stmt = null; String stmtText; try { stmt = new DbSelectStatement(); if (qual == null) stmtText = "SELECT MAX(" + colName + ") AS " + alias + " FROM " + tblName; else stmtText = "SELECT MAX(" + colName + ") AS " + alias + " FROM " + tblName + " " + qual; stmt.create(conn, stmtText); stmt.execute(); if (stmt.next()) { val = stmt.getShortInteger(1); stmt.release(); } /* * else throw new IeciTdException(DbError.EC_NOT_FOUND, * DbError.EM_NOT_FOUND); */ stmt.release(); if (val == DbDataType.NULL_SHORT_INTEGER) val = 0; return val; } catch (Exception e) { DbSelectStatement.ensureRelease(stmt, e); throw e; } }