Package org.teiid.query.sql.proc

Examples of org.teiid.query.sql.proc.LoopStatement


                instruction = new ContinueInstruction();
                break;
            }
            case Statement.TYPE_LOOP:
            {
                LoopStatement loopStmt = (LoopStatement)statement;
                if(debug) {
                  analysisRecord.println("\tLOOP STATEMENT:\n" + statement); //$NON-NLS-1$
                }
                String rsName = loopStmt.getCursorName();

                ProcessorPlan commandPlan = loopStmt.getCommand().getProcessorPlan();

                Program loopProgram = planBlock(parentProcCommand, loopStmt.getBlock(), metadata, debug, idGenerator, capFinder, analysisRecord, context);
                instruction = new LoopInstruction(loopProgram, rsName, commandPlan);
                break;
            }
            case Statement.TYPE_WHILE:
            {
View Full Code Here


                }
                ResolverVisitor.resolveLanguageObject(whileCrit, null, externalGroups, metadata);
                resolveBlock(command, whileStmt.getBlock(), externalGroups, metadata);
                break;
            case Statement.TYPE_LOOP:
                LoopStatement loopStmt = (LoopStatement) statement;
                String groupName = loopStmt.getCursorName();

                if (metadata.getMetadataStore().getTempGroupID(groupName) != null) {
                    throw new QueryResolverException(QueryPlugin.Util.getString("ERR.015.012.0065")); //$NON-NLS-1$
                }
               
            //check - cursor name should not start with #
            if(GroupSymbol.isTempGroupName(loopStmt.getCursorName())){
              String errorMsg = QueryPlugin.Util.getString("ResolveVariablesVisitor.reserved_word_for_temporary_used", loopStmt.getCursorName()); //$NON-NLS-1$
              throw new QueryResolverException(errorMsg);
            }
                Command cmd = loopStmt.getCommand();
                resolveEmbeddedCommand(metadata, externalGroups, cmd);
                List<SingleElementSymbol> symbols = cmd.getProjectedSymbols();
               
                //add the loop cursor group into its own context
                TempMetadataStore store = new TempMetadataStore(new HashMap(metadata.getMetadataStore().getData()));
                metadata = new TempMetadataAdapter(metadata.getMetadata(), store);
                externalGroups = new GroupContext(externalGroups, null);
               
                ProcedureContainerResolver.addScalarGroup(groupName, store, externalGroups, symbols, false);
               
                resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata);
                break;
            case Statement.TYPE_BREAK:
            case Statement.TYPE_CONTINUE:
                break;
            default:
View Full Code Here

                        return null;
                    }
        }
                return statement;
            case Statement.TYPE_LOOP:
                LoopStatement loop = (LoopStatement)statement;
               
                rewriteSubqueryContainer(loop, false);
               
                rewriteBlock(loop.getBlock());
               
                if (loop.getBlock().getStatements().isEmpty()) {
                    return null;
                }
               
                return loop;
            case Statement.TYPE_WHILE:
View Full Code Here

      TeiidComponentException, TeiidProcessingException {
    Block b = new Block();
    b.addStatement(new CommandStatement(newUpdate));
    CreateUpdateProcedureCommand cupc = new CreateUpdateProcedureCommand();
    Block parent = new Block();
    LoopStatement ls = new LoopStatement(b, query, "X"); //$NON-NLS-1$
    parent.addStatement(ls);
    AssignmentStatement as = new AssignmentStatement();
    ElementSymbol rowsUpdate = new ElementSymbol(ProcedureReservedWords.VARIABLES+ElementSymbol.SEPARATOR+ProcedureReservedWords.ROWS_UPDATED);
    as.setVariable(rowsUpdate);
    as.setExpression(new Function("+", new Expression[] {rowsUpdate, new Constant(1)})); //$NON-NLS-1$
View Full Code Here

        block.addStatement(dStmt);
        block.addStatement(assignmentStmt);
       
        String cursor = "mycursor"; //$NON-NLS-1$
              
        LoopStatement loopStmt = new LoopStatement(block, query, cursor);
                       
        helpStmtTest("LOOP ON (SELECT c1, c2 FROM m.g) AS mycursor BEGIN DECLARE integer x; x=mycursor.c1; END", //$NON-NLS-1$
             "LOOP ON (SELECT c1, c2 FROM m.g) AS mycursor"+"\n"+ "BEGIN"+"\n"+"DECLARE integer x;"+"\n"+"x = mycursor.c1;" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
             +"\n"+"END", loopStmt);      //$NON-NLS-1$ //$NON-NLS-2$
   
View Full Code Here

        block.addStatement(dStmt);
        block.addStatement(assignmentStmt);
       
        String cursor = "mycursor"; //$NON-NLS-1$
              
        LoopStatement loopStmt = new LoopStatement(block, query, cursor);
                       
        helpStmtTest("LOOP ON (SELECT c1, c2 FROM m.g ORDER BY c1) AS mycursor BEGIN DECLARE integer x; x=mycursor.c1; END", //$NON-NLS-1$
             "LOOP ON (SELECT c1, c2 FROM m.g ORDER BY c1) AS mycursor"+"\n"+ "BEGIN"+"\n"+"DECLARE integer x;"+"\n"+"x = mycursor.c1;" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
             +"\n"+"END", loopStmt);      //$NON-NLS-1$ //$NON-NLS-2$
   
View Full Code Here

        new Constant(new Integer(5)));
        IfStatement ifStmt = new IfStatement(crit, ifBlock);
        block.addStatement(ifStmt);
       
        String cursor = "mycursor";                //$NON-NLS-1$
        LoopStatement loopStmt = new LoopStatement(block, query, cursor);
       
        block = new Block();       
        block.addStatement(dStmt);
        block.addStatement(loopStmt);
        CommandStatement cmdStmt = new CommandStatement(query);
View Full Code Here

        return q1;
    }
   
    public static final LoopStatement sample1() {
        Block block = TestBlock.sample1();
        return new LoopStatement(block, query1(), "cursor"); //$NON-NLS-1$
    }
View Full Code Here

        return new LoopStatement(block, query1(), "cursor"); //$NON-NLS-1$
    }

    public static final LoopStatement sample2() {
        Block block = TestBlock.sample2();
        return new LoopStatement(block, query2(), "cursor"); //$NON-NLS-1$
    }
View Full Code Here

   
    // ################################## ACTUAL TESTS ################################


    public void testGetBlock() {
        LoopStatement b1 = sample1();
        assertTrue("Incorrect Block on statement", b1.getBlock().equals(TestBlock.sample1())); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.proc.LoopStatement

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.