Package org.teiid.query.sql.lang

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


    public TestRuleValidateWhereAll(String name) {
        super(name);
    }

    public void testHasNoCriteria1() {
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(new Insert())); //$NON-NLS-1$
    }
View Full Code Here


                plan = removeUnnecessaryInlineView(plan, commandRoot);
                QueryCommand queryCommand = createQuery(metadata, capFinder, accessNode, commandRoot);
              addDistinct(metadata, capFinder, accessNode, queryCommand);
                command = queryCommand;
                if (intoGroup != null) {
                  Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
                  insertCommand.setQueryExpression(queryCommand);
                  command = insertCommand;
                }
            }
            if (command != null) {
              accessNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
View Full Code Here

    @Test public void testFailsIllegalOption(){
        TestParser.helpException("SELECT a from g OPTION xyx");         //$NON-NLS-1$
    }
   
    @Test public void testInsertWithOption() {
        Insert insert = new Insert();
        insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        List vars = new ArrayList();
        vars.add(new ElementSymbol("a"));         //$NON-NLS-1$
        insert.setVariables(vars);
        List values = new ArrayList();
        values.add(new Reference(0));
        insert.setValues(values);
        Option option = new Option();
        option.setNoCache(true);      
        insert.setOption(option);
        TestParser.helpTest("INSERT INTO m.g (a) VALUES (?) OPTION NOCACHE"//$NON-NLS-1$
                 "INSERT INTO m.g (a) VALUES (?) OPTION NOCACHE"//$NON-NLS-1$
                 insert);                    
    }
View Full Code Here

    @Test public void testInsertIntoSelect() {
        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
        From from = new From();
        from.addGroup(g);

        Insert insert = new Insert();
        GroupSymbol groupSymbol = new GroupSymbol( "tempA" );   //$NON-NLS-1$
        insert.setGroup(groupSymbol);
       
        Select select = new Select();
//        select.addSymbol( new ExpressionSymbol( new Constant( new Integer(1) ) ) );
        select.addSymbolnew ExpressionSymbol( "exp", new Constant( new Integer(1) ) ) );    //$NON-NLS-1$

        Query query = new Query();
        query.setSelect(select);
       
        insert.setQueryExpression( query );       

        helpTest("insert into tempA SELECT 1"//$NON-NLS-1$
                 "INSERT INTO tempA SELECT 1"//$NON-NLS-1$
                 insert);
    }
View Full Code Here

    helpException("SELECT a, b FROM (SELECT c FROM m.g2)"); //$NON-NLS-1$
  }
       
    /** INSERT INTO m.g (a) VALUES (?) */
    @Test public void testInsertWithReference() {
        Insert insert = new Insert();
        insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        List vars = new ArrayList();
        vars.add(new ElementSymbol("a"));         //$NON-NLS-1$
        insert.setVariables(vars);
        List values = new ArrayList();
        values.add(new Reference(0));
        insert.setValues(values);
        helpTest("INSERT INTO m.g (a) VALUES (?)"//$NON-NLS-1$
                 "INSERT INTO m.g (a) VALUES (?)"//$NON-NLS-1$
                 insert);                    
    }
View Full Code Here

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

        ElementSymbol e =  new ElementSymbol("foo"); //$NON-NLS-1$

        Insert query = new Insert(g, new ArrayList(), new ArrayList());
        query.addVariable(e);
        query.addValue(new Constant("bar", String.class)); //$NON-NLS-1$
       
        helpTest("insert into x (\"foo\") values ('bar')"//$NON-NLS-1$
                 "INSERT INTO x (foo) VALUES ('bar')"//$NON-NLS-1$
                 query);               
    }
View Full Code Here

       
        helpTest("select convert(null, blob), convert(null, clob), convert(null, xml)", "SELECT convert(null, blob), convert(null, clob), convert(null, xml)", query); //$NON-NLS-1$ //$NON-NLS-2$
    }

    @Test public void testInsertWithoutColumns() {
        Insert insert = new Insert();
        insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        insert.addValue(new Constant("a")); //$NON-NLS-1$
        insert.addValue(new Constant("b")); //$NON-NLS-1$
        helpTest("INSERT INTO m.g VALUES ('a', 'b')"//$NON-NLS-1$
                 "INSERT INTO m.g VALUES ('a', 'b')"//$NON-NLS-1$
                 insert);
    }
View Full Code Here

           
            int batchSize = 1;
           
            // ensure that we have the right kind of insert, and that the data for this row is valid
            if (command instanceof Insert) {
              Insert insert = (Insert)command;
              if (insert.isBulk()) {
                    List batch = getBulkRows(insert, insert.getVariables());
                    batchSize = batch.size();
                    assertEquals("Unexpected batch on call " + callCount, expectedBatchSize, batchSize); //$NON-NLS-1$
                   
                    for (int i = 0; i < batchSize; i++) {
                        ensureValue2((List)batch.get(i), 2, ((callCount-1) * batchSize) + i + 1);
                    }
              } else if (insert.getTupleSource() != null) {
                TupleSource ts = insert.getTupleSource();
                List tuple = null;
                int i = 0;
                while ((tuple = ts.nextTuple()) != null) {
                    ensureValue2(tuple, 2, ++i);
                }
View Full Code Here

                return null;
              }
            }
      }
    } if (command instanceof Insert) {
      Insert obj = (Insert)command;
      for (int i = 0; i < obj.getVariables().size(); i++) {
        ElementSymbol elem = obj.getVariables().get(i);
            Object metadataID = elem.getMetadataID();           
            if(metadataID instanceof MultiSourceElement) {
              Constant source = (Constant)obj.getValues().get(i);
            obj.getVariables().remove(i);
            obj.getValues().remove(i);
              if (!source.getValue().equals(sourceName)) {
                return null;
              }
            }
      }
View Full Code Here

            return null;
          }
          final String groupKey = group.getNonCorrelationName().toUpperCase();
            final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, false);
          if (command instanceof Insert) {
            Insert insert = (Insert)command;
            TupleSource ts = insert.getTupleSource();
            if (ts == null) {
              List<Object> values = new ArrayList<Object>(insert.getValues().size());
              for (Expression expr : (List<Expression>)insert.getValues()) {
                values.add(Evaluator.evaluate(expr));
          }
              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());
View Full Code Here

TOP

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

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.