Ejemplo n.º 1
0
  /**
   * Binds the value in the specified update descriptor corresponding with the specified column
   * reference to the specified statement.
   *
   * @param stmt the statement
   * @param columnRef the column reference
   * @param updateDesc the update descriptor
   * @throws SQLException thrown by setter methods on java.sql.PreparedStatement
   */
  private void bindInputColumn(
      DBStatement stmt,
      ColumnRef columnRef,
      UpdateObjectDescImpl updateDesc,
      boolean getBeforeValue)
      throws SQLException {

    Object inputValue = getInputValue(updateDesc, columnRef, getBeforeValue);
    stmt.bindInputColumn(
        columnRef.getIndex(), inputValue, columnRef.getColumnElement(), vendorType);
  }
Ejemplo n.º 2
0
  private StringBuffer generateColumnText() {
    StringBuffer columnList = new StringBuffer();
    int numValues = -1;

    for (int i = 0; i < columns.size(); i++) {
      ColumnRef c = (ColumnRef) columns.get(i);

      if (columnList.length() > 0) {
        columnList.append(", "); // NOI18N
      }
      switch (action) {
        case QueryPlan.ACT_UPDATE:
          appendQuotedText(columnList, c.getName());
          columnList.append("= ?"); // NOI18N
          break;

        case QueryPlan.ACT_INSERT:
          appendQuotedText(columnList, c.getName());
          if (i == 0) {
            values = new StringBuffer().append(" ?"); // NOI18N
          } else {
            values.append(", ?"); // NOI18N
          }
          break;
      }

      // Do not create an InputValue in the case of batch update.
      // Method bindInputValues will get the value using the ColumnRef.
      if (!batch && ((action == QueryPlan.ACT_UPDATE) || (action == QueryPlan.ACT_INSERT))) {
        numValues = numValues + 1;
        InputValue val = new InputValue(c.getValue(), c.getColumnElement());
        inputDesc.values.add(numValues, val);
      }
    }

    appendVersionColumnUpdateClause(columnList);

    return columnList;
  }