@Override
 public void visit(Update obj) {
   preVisitVisitor(obj);
   visitNode(obj.getGroup());
   visitNode(obj.getChangeList());
   visitNode(obj.getCriteria());
   visitNode(obj.getOption());
   postVisitVisitor(obj);
 }
Beispiel #2
0
  /**
   * @see
   *     org.teiid.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(org.teiid.query.sql.lang.Command,
   *     org.teiid.query.metadata.TempMetadataAdapter)
   */
  public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata)
      throws QueryMetadataException, QueryResolverException, TeiidComponentException {

    // Cast to known type
    Update update = (Update) command;

    // Resolve elements and functions
    Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
    groups.add(update.getGroup());
    for (SetClause clause : update.getChangeList().getClauses()) {
      ResolverVisitor.resolveLanguageObject(clause.getSymbol(), groups, null, metadata);
    }
    QueryResolver.resolveSubqueries(command, metadata, groups);
    ResolverVisitor.resolveLanguageObject(
        update, groups, update.getExternalGroupContexts(), metadata);
  }
Beispiel #3
0
  /**
   * @see
   *     org.teiid.query.resolver.VariableResolver#getVariableValues(org.teiid.query.sql.lang.Command,
   *     org.teiid.query.metadata.QueryMetadataInterface)
   */
  public Map<ElementSymbol, Expression> getVariableValues(
      Command command, boolean changingOnly, QueryMetadataInterface metadata)
      throws QueryMetadataException, TeiidComponentException {
    Map<ElementSymbol, Expression> result = new HashMap<ElementSymbol, Expression>();

    Update update = (Update) command;

    Map<ElementSymbol, Expression> changing = update.getChangeList().getClauseMap();

    for (Entry<ElementSymbol, Expression> entry : changing.entrySet()) {
      ElementSymbol leftSymbol = entry.getKey().clone();
      leftSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
      leftSymbol.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
      result.put(leftSymbol, new Constant(Boolean.TRUE));
      if (!changingOnly) {
        leftSymbol = entry.getKey().clone();
        leftSymbol.getGroupSymbol().setName(SQLConstants.Reserved.NEW);
        result.put(leftSymbol, entry.getValue());
      }
    }

    Collection<ElementSymbol> insertElmnts =
        ResolverUtil.resolveElementsInGroup(update.getGroup(), metadata);

    insertElmnts.removeAll(changing.keySet());

    Iterator<ElementSymbol> defaultIter = insertElmnts.iterator();
    while (defaultIter.hasNext()) {
      ElementSymbol varSymbol = defaultIter.next().clone();
      varSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
      varSymbol.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
      result.put(varSymbol, new Constant(Boolean.FALSE));
    }

    return result;
  }