public static void mergeSort(ResultSet[] outResults, ProcedureExecutionContext context)
      throws SQLException {

    Connection cxn = context.getConnection();
    String tableName = context.getTableName();
    if (tableName == null || tableName.length() == 0) {
      // some default table in case no ON TABLE was used in execution
      tableName = "EMP.PARTITIONTESTTABLE";
    }
    // some fixed column being used for ordering here; instead the code can
    // find out the schema of the table and use some column
    String queryString = "<local> SELECT * FROM " + tableName + " ORDER BY SECONDID";
    Statement stmt = cxn.createStatement();
    ResultSet rs = stmt.executeQuery(queryString);
    outResults[0] = rs;
    // Do not close the connection since this would also
    // close the result set.
  }
Example #2
0
  public static void selectGfxdBuyordersByTidList(
      int oid, int tid, ResultSet[] rs, ProcedureExecutionContext context) throws SQLException {
    // public static void selectGfxdBuyordersByTidList(int oid, int tid,
    // ResultSet[] rs,
    // ProcedureExecutionContext c) throws SQLException {
    // context = c;
    // to reproduce
    Connection conn = context.getConnection();

    if (context.getTableName() == null) {
      throw new TestException(
          "ProcedureExecutionContext.getTableName() is : " + context.getTableName());
    }
    if (!selectBuyOrderByTidListSql.contains(context.getTableName())) {
      throw new TestException(
          "ProcedureExecutionContext.getTableName() is incorrect: " + context.getTableName());
    } // #42836 is fixed
    if (!SQLTest.isHATest && context.isPossibleDuplicate()) {
      throw new TestException("possible duplicate is true and this is not a HA test.");
    }

    /*
    boolean isPortfolioPartitioned = ((ArrayList<String> )SQLBB.getBB().getSharedMap().
        get("buyordersPartition")).size() !=0;
    if (context.isPartitioned(context.getTableName()) != isPortfolioPartitioned) {
      throw new TestException("context reports that the table partition is " +
          context.isPartitioned(context.getTableName()) + ", but it is " + isPortfolioPartitioned);
    }  //work around #43039select cid, sid, subTotal "
    */
    // test only with invocation with where clause so the <local> is optional
    // here
    // String withLocal = (oid/2==0)? LOCAL : "" ;
    String withLocal = LOCAL;
    String sql = withLocal + selectBuyOrderByTidListSql;
    PreparedStatement ps1 = conn.prepareStatement(sql);
    ps1.setInt(1, oid);
    ps1.setInt(2, tid);

    rs[0] = ps1.executeQuery();

    // conn.close();
  }