Ejemplo n.º 1
0
  public static void select(
      DbConnection conn, String sqlCompleta, DbOutputPaginatedRecordSet rs, PageInfo pageInfo)
      throws Exception {
    DbSelectStatement stmt = null;
    DbOutputRecord rec;

    try {
      stmt = new DbSelectStatement();
      /* String sql = */ stmt.createScrollable(conn, sqlCompleta);
      stmt.execute();

      int initialRecordNumber = pageInfo.getInitialRecordNumber();
      if (initialRecordNumber > 0) stmt.absolut(initialRecordNumber);

      int count = 0;
      while (stmt.next() && count++ < rs.getMaxNumItems()) {
        rec = rs.newRecord();
        rec.getStatementValues(stmt);
      }

      stmt.release();
    } catch (Exception e) {
      DbSelectStatement.ensureRelease(stmt, e);
    }
  }
Ejemplo n.º 2
0
  public static void select(
      DbConnection conn,
      String tblNames,
      String colNames,
      String qual,
      boolean distinct,
      String hint,
      DbOutputPaginatedRecordSet rs,
      PageInfo pageInfo)
      throws Exception {
    DbSelectStatement stmt = null;
    DbOutputRecord rec;

    try {
      stmt = new DbSelectStatement();

      if (conn.isAllowHint()) {
        /* String sql = */ stmt.createScrollable(conn, tblNames, colNames, qual, distinct, hint);
      } else {
        /* String sql = */ stmt.createScrollable(conn, tblNames, colNames, qual, distinct);
      }
      stmt.execute();

      int initialRecordNumber = pageInfo.getInitialRecordNumber();
      if (initialRecordNumber > 0) stmt.absolut(initialRecordNumber);

      int count = 0;
      while (stmt.next() && count++ < rs.getMaxNumItems()) {
        rec = rs.newRecord();
        rec.getStatementValues(stmt);
      }

      stmt.release();
    } catch (Exception e) {
      DbSelectStatement.ensureRelease(stmt, e);
    }
  }