Package org.teiid.query.sql.lang

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


               
    static List getProcResultSetSymbols(List params){
      List result = new ArrayList();
      Iterator iter = params.iterator();
      while(iter.hasNext()){
        SPParameter param = (SPParameter)iter.next();
        if(param.getResultSetColumns() != null){
          result.addAll(param.getResultSetColumns());
        }
      }
      iter = params.iterator();
      while(iter.hasNext()){
        SPParameter param = (SPParameter)iter.next();
            if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
                result.add(param.getParameterSymbol());
            }
      }
      return result;
    }     
View Full Code Here


    }
   
    @Test public void testCacheHintCallableStatement() {
        String sql = "/*+ cache */ { ? = call proc() }"; //$NON-NLS-1$
        StoredProcedure sp = new StoredProcedure();
        SPParameter param = new SPParameter(1, null);
        param.setParameterType(SPParameter.RETURN_VALUE);
        sp.setParameter(param);
        sp.setProcedureName("proc");
        sp.setCallableStatement(true);
        CacheHint hint = new CacheHint();
        sp.setCacheHint(hint);
View Full Code Here

        List params = proc.getParameters();

        // Remove all but IN and IN/OUT params
        Iterator paramIter = params.iterator();
        while (paramIter.hasNext()) {
            final SPParameter param = (SPParameter)paramIter.next();
            if (param.getParameterType() != ParameterInfo.IN && param.getParameterType() != ParameterInfo.INOUT) {
                paramIter.remove();
            }
        }

        // Check remaining params against expected expressions
        assertEquals(expectedParameterExpressions.length, params.size());
        for (int i=0; i<expectedParameterExpressions.length; i++) {
            SPParameter param = (SPParameter)params.get(i);
            if (expectedParameterExpressions[i] == null) {
                assertNull(param.getExpression());
            } else {
                assertEquals(expectedParameterExpressions[i], param.getExpression());
            }
        }
       
        return proc;
    }
View Full Code Here

        // 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.RESULT_SET, 1, "pm1.sq2.ret", java.sql.ResultSet.class, null); //$NON-NLS-1$

        SPParameter param2 = (SPParameter) params.get(1);
        helpCheckParameter(param2, ParameterInfo.IN, 2, "pm1.sq2.in", DataTypeManager.DefaultDataClasses.STRING, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

    // 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$

    SPParameter param2 = (SPParameter) params.get(1);
    helpCheckParameter(param2, ParameterInfo.IN, 3, "pm1.sq3a.in2", DataTypeManager.DefaultDataClasses.INTEGER, new Constant(new Integer(123))); //$NON-NLS-1$
  }   
View Full Code Here

        AnalysisRecord analysis = AnalysisRecord.createNonRecordingRecord();
       
        Query query = (Query) helpResolve(userSql, metadata);
        From from = query.getFrom();
        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;
                    } else {
                        params[1] = param;
                    }
View Full Code Here

            List conjuncts = new LinkedList();
            HashSet coveredParams = new HashSet();
            //List preExecNodes = new LinkedList();
                       
            for (Iterator params = proc.getInputParameters().iterator(); params.hasNext();) {
                SPParameter param = (SPParameter)params.next();
                ElementSymbol symbol = param.getParameterSymbol();
                Expression input = param.getExpression();
                inputReferences.add(input);
                inputSymbols.add(symbol);
            }
           
            findInputNodes(inputSymbols, critNode, conjuncts, coveredParams);
View Full Code Here

  private Command rewriteCommand(String sourceName, Command command) throws ExpressionEvaluationException, TeiidComponentException {
    if (command instanceof StoredProcedure) {
      StoredProcedure obj = (StoredProcedure)command;
      for (Iterator<SPParameter> params = obj.getMapOfParameters().values().iterator(); params.hasNext();) {
        SPParameter param = params.next();
        if (param.getParameterType() != SPParameter.IN) {
          continue;
        }
        String shortName = SingleElementSymbol.getShortName(param.getName());       
          if(shortName.equalsIgnoreCase(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME)) {
              Constant source = (Constant)param.getExpression();
            params.remove();
            if (param.isUsingDefault() && source.isNull()) {
              continue;
            }
              if (!source.getValue().equals(sourceName)) {
                return null;
              }
View Full Code Here

   
    private static List getProcResultSetSymbols(List params){
        List result = new ArrayList();
        Iterator iter = params.iterator();
        while(iter.hasNext()){
            SPParameter param = (SPParameter)iter.next();
            if(param.getResultSetColumns() != null){
                result.addAll(param.getResultSetColumns());
            }
        }
        iter = params.iterator();
        while(iter.hasNext()){
            SPParameter param = (SPParameter)iter.next();
            if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
                result.add(param.getParameterSymbol());
            }
        }
        return result;
    }
View Full Code Here

            } else if (metadataParameter.getParameterType() == ParameterInfo.OUT) {
              outParams++;
            } else if (metadataParameter.getParameterType() == ParameterInfo.RETURN_VALUE) {
              hasReturnValue = true;
            }
            SPParameter clonedParam = (SPParameter)metadataParameter.clone();
            clonedMetadataParams.add(clonedParam);
            storedProcedureCommand.setParameter(clonedParam);
        }
       
        if (storedProcedureCommand.isCalledWithReturn() && !hasReturnValue) {
View Full Code Here

TOP

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

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.