Package org.teiid.query.sql.lang

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


          public TupleSource registerRequest(CommandContext context,
              Command command, String modelName,
              String connectorBindingId, int nodeID, int limit)
              throws TeiidComponentException {
            if (command instanceof StoredProcedure) {
              StoredProcedure proc = (StoredProcedure)command;
              List<SPParameter> params = proc.getInputParameters();
              assertEquals(1, params.size());
              int value = (Integer)((Constant)params.get(0).getExpression()).getValue();
              return new FakeTupleSource(command.getProjectedSymbols(), new List[] {
                Arrays.asList(value+2), Arrays.asList(value+5)
              });
View Full Code Here


   * When the user's query is parsed and resolved, the placeholder
   * input params are numbered #1 and #2.  This test tests that this disparity in ordering should not
   * be a problem as long as RELATIVE ordering is in synch.
   */
  @Test public void testStoredQueryParamOrdering_8211() {               
    StoredProcedure proc = (StoredProcedure) helpResolve("EXEC pm1.sq3a('abc', 123)"); //$NON-NLS-1$
   
    // Check number of resolved parameters
    List params = proc.getParameters();
    assertEquals("Did not get expected parameter count", 2, params.size()); //$NON-NLS-1$
       
    // Check resolved parameters
    SPParameter param1 = (SPParameter) params.get(0);
    helpCheckParameter(param1, ParameterInfo.IN, 1, "pm1.sq3a.in", DataTypeManager.DefaultDataClasses.STRING, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        assertEquals("procedure_name", sp.getProcedureName()); //$NON-NLS-1$
        assertEquals((returnValue ? "? = ":"") +"EXEC procedure_name(?, ?, ?)", sp.toString()); //$NON-NLS-1$
    }
           
    @Test public void testCallNoParams() throws QueryParserException {
        StoredProcedure sp = (StoredProcedure)QueryParser.getQueryParser().parseCommand("{call procedure_name}"); //$NON-NLS-1$
        assertFalse(sp.returnsScalarValue());
        assertEquals("procedure_name", sp.getProcedureName()); //$NON-NLS-1$
        assertEquals(0, sp.getParameters().size());
    }
View Full Code Here

    }   

    /** test omitting a required parameter that has a default value */
    @Test public void testExecNamedParamsOmitRequiredParamWithDefaultValue() {
        Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(new Integer(666)), new Constant("YYZ")};//$NON-NLS-1$ //$NON-NLS-2$
        StoredProcedure sp = helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in2 = 666)", expectedParameterExpressions);//$NON-NLS-1$
        assertEquals("EXEC pm1.sq3b(\"in\" => 'xyz', in2 => 666)", sp.toString());
    }   
View Full Code Here

        Collection fromClauses = from.getClauses();
        SPParameter params[] = new SPParameter[2];
        Iterator iter = fromClauses.iterator();
        while(iter.hasNext()) {
            SubqueryFromClause clause = (SubqueryFromClause) iter.next();
            StoredProcedure proc = (StoredProcedure) clause.getCommand();
            List procParams = proc.getParameters();
            for(int i=0; i<procParams.size(); i++) {
                SPParameter param = (SPParameter) procParams.get(i);
                if(param.getParameterType() == ParameterInfo.IN) {
                    if(params[0] == null) {
                        params[0] = param;
View Full Code Here

    }
   
    @Test public void testExecProjectedSymbols() {
        String query = "exec pm1.sq1()"; //$NON-NLS-1$
        
        StoredProcedure proc = (StoredProcedure)helpResolve(query);
       
        List projected = proc.getProjectedSymbols();
       
        assertEquals(2, projected.size());
       
        for (Iterator i = projected.iterator(); i.hasNext();) {
            ElementSymbol symbol = (ElementSymbol)i.next();
View Full Code Here

        Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, e2 as x, e3 as e2 FROM pm1.g1 ORDER BY x, e2 "); //$NON-NLS-1$
        helpTestOrderBy(resolvedQuery.getOrderBy(), new int[] {1, 2});
    }
   
    @Test public void testSPOutParamWithExec() {
      StoredProcedure proc = (StoredProcedure)helpResolve("exec pm2.spTest8(1)", FakeMetadataFactory.exampleBQTCached());
      assertEquals(2, proc.getProjectedSymbols().size());
    }
View Full Code Here

    /**
     * Note that the call syntax is not quite correct, the output parameter is not in the arg list.
     * That hack is handled by the PreparedStatementRequest
     */
    @Test public void testSPOutParamWithCallableStatement() {
      StoredProcedure proc = (StoredProcedure)helpResolve("{call pm2.spTest8(1)}", FakeMetadataFactory.exampleBQTCached());
      assertEquals(3, proc.getProjectedSymbols().size());
    }
View Full Code Here

      Query proc = (Query)helpResolve("select * from pm2.spTest8 where inkey = 1", FakeMetadataFactory.exampleBQTCached());
      assertEquals(3, proc.getProjectedSymbols().size());
    }
   
    @Test public void testSPReturnParamWithNoResultSet() {
      StoredProcedure proc = (StoredProcedure)helpResolve("exec pm4.spTest9(1)", FakeMetadataFactory.exampleBQTCached());
      assertEquals(1, proc.getProjectedSymbols().size());
    }
View Full Code Here

           "END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
           "var2 = (SELECT b1 FROM g, /*+ optional */ h WHERE a2 = 5);"+"\n"+"END"+"\n"+"END", cmd);                      //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    }

    @Test public void testStoredQueryWithOption(){
        StoredProcedure storedQuery = new StoredProcedure();
        storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
        Option option = new Option();
        option.setNoCache(true);
        storedQuery.setOption(option);
        TestParser.helpTest("exec proc1() option nocache", "EXEC proc1() OPTION NOCACHE", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

TOP

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

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.