Examples of VariableContext


Examples of org.teiid.query.sql.util.VariableContext

  public void open()
    throws TeiidComponentException, TeiidProcessingException {
    super.open();
        // Initialize plan for execution
        CommandContext subContext = getContext().clone();
        subContext.pushVariableContext(new VariableContext());
        plan.initialize(subContext, getDataManager(), this.getBufferManager());       
       
        if (openPlanImmediately() && prepareNextCommand()) {
            needsProcessing = true;
            plan.open();
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

   *             if this processing the plan throws a currentVarContext
   */
  public void process(ProcedurePlan procEnv) throws BlockedException,
      TeiidComponentException, TeiidProcessingException {

    VariableContext localContext = procEnv.getCurrentVariableContext();

    try {
      Object value = procEnv.evaluateExpression(dynamicCommand.getSql());

      if (value == null) {
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

        this.loopProgram = loopProgram;
    }

    public void process(ProcedurePlan procEnv) throws TeiidComponentException {
        List currentRow = procEnv.getCurrentRow(rsName);
        VariableContext varContext = procEnv.getCurrentVariableContext();
        //set results to the variable context(the cursor.element is treated as variable)
        if(this.elements == null){
            List schema = procEnv.getSchema(rsName);
            elements = new ArrayList(schema.size());
            for(int i=0; i< schema.size(); i++){
                // defect 13432 - schema may contain AliasSymbols. Cast to SingleElementSymbol instead of ElementSymbol
                SingleElementSymbol element = (SingleElementSymbol)schema.get(i);
                elements.add(new ElementSymbol(rsName + "." + element.getShortName()));              //$NON-NLS-1$
            }
        }
        for(int i=0; i< elements.size(); i++){
            varContext.setValue((ElementSymbol)elements.get(i), currentRow.get(i));              
        }
    }
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

   * @throws TeiidComponentException if error processing command or expression on this instruction
     */
    public void process(ProcedurePlan procEnv) throws BlockedException,
                                               TeiidComponentException, TeiidProcessingException {

        VariableContext varContext = procEnv.getCurrentVariableContext();
        Object value = null;
        if (this.expression != null) {
          value = procEnv.evaluateExpression(this.expression);
        }
        varContext.setValue(getVariable(), value);
        LogManager.logTrace(LogConstants.CTX_DQP,
                            new Object[] {this.toString() + " The variable " //$NON-NLS-1$
                                          + getVariable() + " in the variablecontext is updated with the value :", value}); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

        commands.add(command);
      }
    }
   
    if (paramValues.size() > 1) {
      this.context.setVariableContext(new VariableContext());
    }
   
    if (paramValues.size() == 1) {
      return; // just use the existing plan, and global reference evaluation
    }
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

   * @throws QueryResolverException
   * @throws QueryValidatorException
   */
  public static void resolveParameterValues(List<Reference> params,
                                      List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException, QueryValidatorException {
    VariableContext result = new VariableContext();
      //the size of the values must be the same as that of the parameters
      if (params.size() != values.size()) {
          String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
          throw new QueryResolverException(msg);
      }
 
      //the type must be the same, or the type of the value can be implicitly converted
      //to that of the reference
      for (int i = 0; i < params.size(); i++) {
          Reference param = params.get(i);
          Object value = values.get(i);
         
          //TODO: why is the list check in here
          if(value != null && !(value instanceof List)) {
                try {
                    String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
                    Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName, metadata);
                    value = Evaluator.evaluate(expr);
        } catch (ExpressionEvaluationException e) {
                    String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
                    throw new QueryResolverException(msg);
        } catch (QueryResolverException e) {
          String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
                    throw new QueryResolverException(msg);
        }
          }
                   
          if (param.getConstraint() != null) {
            param.getConstraint().validate(value);
          }
          //bind variable
          result.setGlobalValue(param.getContextSymbol(), value);
      }
     
      context.setVariableContext(result);
  }
View Full Code Here

Examples of org.teiid.query.sql.util.VariableContext

          pp.setAnalysisRecord(record);
          pp.setCommand(newCommand);
          commandContext.putPlan(query, pp, copy.getDeterminismLevel());
          copy.setDeterminismLevel(determinismLevel);
    }
    copy.pushVariableContext(new VariableContext());
    PreparedStatementRequest.resolveParameterValues(pp.getReferences(), Arrays.asList(params), copy, metadata);
        return new QueryProcessor(pp.getPlan().clone(), copy, bufferMgr, dataMgr);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.