Package org.teiid.query.sql.lang

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


      if(command instanceof Query) {
            Query query = (Query) command;
            return query.getCriteria() == null;
        }
        if (command instanceof Delete) {
          Delete query = (Delete) command;
            return query.getCriteria() == null;
        }
        if (command instanceof Update) {
          Update query = (Update) command;
            return query.getCriteria() == null;
        }
        if (command instanceof SetQuery) {
          SetQuery query = (SetQuery)command;
          return hasNoCriteria(query.getLeftQuery()) || hasNoCriteria(query.getRightQuery());
        }
        return false;
    }
View Full Code Here


                 "INSERT INTO m.g (a) VALUES (?) OPTION NOCACHE"//$NON-NLS-1$
                 insert);                    
    }
   
    @Test public void testDeleteWithOption() {
        Delete delete = new Delete();
        delete.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        Option option = new Option();
        option.setNoCache(true);      
        delete.setOption(option);
        TestParser.helpTest("DELETE FROM m.g OPTION NOCACHE"//$NON-NLS-1$
                 "DELETE FROM m.g OPTION NOCACHE"//$NON-NLS-1$
                 delete);                    
    }
View Full Code Here

        From from = new From();
        from.addGroup(g);

        ElementSymbol e =  new ElementSymbol("foo"); //$NON-NLS-1$
        CompareCriteria c = new CompareCriteria(e, CompareCriteria.EQ, new Constant("bar", String.class)); //$NON-NLS-1$
        Delete query = new Delete(g,c);
       
        helpTest("delete from x where \"foo\"='bar'"//$NON-NLS-1$
                 "DELETE FROM x WHERE foo = 'bar'"//$NON-NLS-1$
                 query);               
    }   
View Full Code Here

            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) {
              //because we are non-transactional, just use a truncate
              int rows = table.truncate();
                    return CollectionTupleSource.createUpdateCountTupleSource(rows);
            }
View Full Code Here

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

     */
    public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata)
        throws QueryMetadataException, QueryResolverException, TeiidComponentException {

        //Cast to known type
        Delete delete = (Delete) command;

        Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
        groups.add(delete.getGroup());
        QueryResolver.resolveSubqueries(command, metadata, groups);
        ResolverVisitor.resolveLanguageObject(delete, groups, delete.getExternalGroupContexts(), metadata);
    }
View Full Code Here

   
        helpTest(comp, "(m.g.c1 = 'abc') OR (<undefined>)"); //$NON-NLS-1$
    }       
   
    public void testDelete1() {
      Delete delete = new Delete();
      delete.setGroup(new GroupSymbol("m.g"));     //$NON-NLS-1$
     
      helpTest(delete, "DELETE FROM m.g"); //$NON-NLS-1$
    }
View Full Code Here

     
      helpTest(delete, "DELETE FROM m.g"); //$NON-NLS-1$
    }

    public void testDelete2() {
      Delete delete = new Delete();
      delete.setGroup(new GroupSymbol("m.g"));    //$NON-NLS-1$
      delete.setCriteria(new CompareCriteria(
            new ElementSymbol("m.g.c1"), //$NON-NLS-1$
            CompareCriteria.EQ,
            new Constant("abc")) ); //$NON-NLS-1$
      
     
View Full Code Here

      CommandStatement cmdStmt =  new CommandStatement(q1);
    helpTest(cmdStmt, "SELECT x FROM g;"); //$NON-NLS-1$
    }
   
    public void testCommandStatement2() {
        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
    helpTest(cmdStmt, "DELETE FROM g;"); //$NON-NLS-1$
    }
View Full Code Here

      CommandStatement cmdStmt =  new CommandStatement(d1);
    helpTest(cmdStmt, "DELETE FROM g;"); //$NON-NLS-1$
    }
   
    public void testBlock1() {
        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block b = new Block();
      b.addStatement(cmdStmt);
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Delete

Copyright © 2018 www.massapicom. 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.