Examples of Update


Examples of org.teiid.query.sql.lang.Update

 
     
    @Test public void testUpdateSetClauseReferenceType() {
      String sql = "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = ?;"; //$NON-NLS-1$
     
      Update update = (Update)helpResolve(sql, FakeMetadataFactory.example1Cached());
     
      Expression ref = update.getChangeList().getClauses().get(1).getValue();
      assertTrue(ref instanceof Reference);
      assertNotNull(ref.getType());
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

                Arrays.asList(4)
        };
     
      // Create the plan and process the query
      TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false,FakeMetadataFactory.example1VDB());
      Update update = (Update)dataManager.getCommandHistory().iterator().next();
      assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

              ts = new CollectionTupleSource(Arrays.asList(values).iterator());
            }
            return table.insert(ts, insert.getVariables());
          }
          if (command instanceof Update) {
            final Update update = (Update)command;
            final Criteria crit = update.getCriteria();
            return table.update(crit, update.getChangeList());
          }
          if (command instanceof Delete) {
            final Delete delete = (Delete)command;
            final Criteria crit = delete.getCriteria();
            if (crit == null) {
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

     */
    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);
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

    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);
            result.put(leftSymbol, new Constant(Boolean.TRUE));
            if (!changingOnly) {
              leftSymbol = leftSymbol.clone();
              leftSymbol.getGroupSymbol().setName(ProcedureReservedWords.INPUTS);
              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()) {
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

            case Statement.TYPE_COMMAND:
        CommandStatement cmdStmt = (CommandStatement) statement;
                rewriteSubqueryContainer(cmdStmt, false);
               
        if(cmdStmt.getCommand().getType() == Command.TYPE_UPDATE) {
                    Update update = (Update)cmdStmt.getCommand();
                    if (update.getChangeList().isEmpty()) {
                        return null;
                    }
        }
                return statement;
            case Statement.TYPE_LOOP:
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

  private Command createUpdateProcedure(Update update, Query query,
      GroupSymbol group, String correlationName)
      throws TeiidComponentException, QueryMetadataException,
      QueryResolverException, TeiidProcessingException {
    Update newUpdate = new Update();
    newUpdate.setChangeList(update.getChangeList());
    newUpdate.setGroup(group.clone());
    List<Criteria> pkCriteria = createPkCriteria(group, correlationName, query);
    newUpdate.setCriteria(new CompoundCriteria(pkCriteria));
    return asLoopProcedure(update.getGroup(), query, newUpdate);
  }
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

        GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
        From from = new From();
        from.addGroup(g);

        ElementSymbol e =  new ElementSymbol("foo"); //$NON-NLS-1$
        Update query = new Update();
        query.setGroup(g);
        query.addChange(e, new Constant("bar", String.class)); //$NON-NLS-1$
       
        helpTest("update x set \"foo\"='bar'"//$NON-NLS-1$
                 "UPDATE x SET foo = 'bar'"//$NON-NLS-1$
                 query);               
   
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

              if (expr != null) {
                return shouldExecute(expr, simplifyCriteria);
              }
              return true;
            case Command.TYPE_UPDATE:
                Update update = (Update) command;
               
                if (update.getChangeList().isEmpty()) {
                    return false;
                }
               
                criteria = update.getCriteria();
                // If there are elements present in the criteria,
                // then we don't know the result, so assume we need to execute
                if (criteria == null) {
                  return true;
                }
                if(!EvaluatableVisitor.isFullyEvaluatable(criteria, duringPlanning)) {
                    return true;
                } else if(Evaluator.evaluate(criteria)) {
                    if (simplifyCriteria) {
                        update.setCriteria(null);
                    }
                    return true;
                }
                break;
            case Command.TYPE_DELETE:
View Full Code Here

Examples of org.teiid.query.sql.lang.Update

        unaryFromClause.setOptional(true);
        helpTest(unaryFromClause, "/*+ optional */ m.g1");     //$NON-NLS-1$
    }
 
  public void testUpdate1() {
    Update update = new Update();
    update.setGroup(new GroupSymbol("m.g1"));     //$NON-NLS-1$
    update.addChange(new ElementSymbol("e1"), new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
   
    helpTest(update, "UPDATE m.g1 SET e1 = 'abc'"); //$NON-NLS-1$
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.