Package org.apache.derby.iapi.types

Examples of org.apache.derby.iapi.types.DataTypeDescriptor


  /*
  ** set result type for operator
  */
  private void setResultType(TypeId resultType) throws StandardException
  {
    setType(new DataTypeDescriptor(
            resultType,
            true,
            receiver.getTypeServices().getMaximumWidth()
          )
        );
View Full Code Here


     * Is there a ? paramter for the third arg.  It will be an int.
     */
    if( rightOperand.requiresTypeFromContext())
    {
      rightOperand.setType(
        new DataTypeDescriptor(TypeId.INTEGER_ID, true));
    }

    bindToBuiltIn();

    /*
    ** Check the type of the operand - this function is allowed only
    ** for: receiver = CHAR
    **      firstOperand = CHAR
    **      secondOperand = INT
    */
    secondOperandType = leftOperand.getTypeId();
    offsetType = rightOperand.getTypeId();
    firstOperandType = receiver.getTypeId();

    if (!firstOperandType.isStringTypeId() ||
      !secondOperandType.isStringTypeId() ||
      offsetType.getJDBCTypeId() != Types.INTEGER)
      throw StandardException.newException(SQLState.LANG_DB2_FUNCTION_INCOMPATIBLE,
          "LOCATE", "FUNCTION");

    /*
    ** The result type of a LocateFunctionNode is an integer.
    */
    setType(new DataTypeDescriptor(TypeId.INTEGER_ID,
        receiver.getTypeServices().isNullable()));

    return this;
  }
View Full Code Here

  protected ValueNode castArgToString(ValueNode vn) throws StandardException
  {
    TypeCompiler vnTC = vn.getTypeCompiler();
    if (! vn.getTypeId().isStringTypeId())
    {
      DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, true,
                  vnTC.getCastToCharWidth(
                        vn.getTypeServices()));
      // DERBY-2910 - Match current schema collation for implicit cast as we do for
      // explicit casts per SQL Spec 6.12 (10)                                 
      dtd.setCollationType(getSchemaDescriptor(null).getCollationType());
      dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
      ValueNode newNode = (ValueNode)
            getNodeFactory().getNode(
              C_NodeTypes.CAST_NODE,
              vn,
              dtd,
View Full Code Here

    /* Is there a ? parameter on the left? */
    if (leftOperand.requiresTypeFromContext())
    {
      /* Set the left operand type to int. */
      leftOperand.setType(             
        new DataTypeDescriptor(TypeId.INTEGER_ID, true));
    }

    /* Is there a ? parameter on the right? */
    if ((rightOperand != null) && rightOperand.requiresTypeFromContext())
    {
      /* Set the right operand type to int. */
      rightOperand.setType(             
        new DataTypeDescriptor(TypeId.INTEGER_ID, true));
    }

    bindToBuiltIn();

    if (!leftOperand.getTypeId().isNumericTypeId() ||
      (rightOperand != null && !rightOperand.getTypeId().isNumericTypeId()))
      throw StandardException.newException(SQLState.LANG_DB2_FUNCTION_INCOMPATIBLE, "SUBSTR", "FUNCTION");

    /*
    ** Check the type of the receiver - this function is allowed only on
    ** string value types. 
    */
    receiverType = receiver.getTypeId();
    switch (receiverType.getJDBCTypeId())
    {
      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
      case Types.CLOB:
        break;
      default:
      {
        throwBadType("SUBSTR", receiverType.getSQLTypeName());
      }
    }
    if (receiverType.getTypeFormatId() == StoredFormatIds.CLOB_TYPE_ID) {
    // special case for CLOBs: if we start with a CLOB, we have to get
    // a CLOB as a result (as opposed to a VARCHAR), because we can have a
    // CLOB that is beyond the max length of VARCHAR (ex. "clob(100k)").
    // This is okay because CLOBs, like VARCHARs, allow variable-length
    // values (which is a must for the substr to actually work).
      resultType = receiverType;
    }

    // Determine the maximum length of the result
    int resultLen = receiver.getTypeServices().getMaximumWidth();

    if (rightOperand != null && rightOperand instanceof ConstantNode)
    {
      if (((ConstantNode)rightOperand).getValue().getInt() < resultLen)
        resultLen = ((ConstantNode)rightOperand).getValue().getInt();
    }

    /*
    ** The result type of substr is a string type
    */
    setType(new DataTypeDescriptor(
            resultType,
            true,
            resultLen
          ));
    //Result of SUSBSTR should pick up the collation of the 1st argument
View Full Code Here

     */
    private boolean bindParameter( ValueNode arg, int jdbcType) throws StandardException
    {
        if( arg.requiresTypeFromContext() && arg.getTypeId() == null)
        {
            arg.setType( new DataTypeDescriptor(TypeId.getBuiltInTypeId( jdbcType), true));
            return true;
        }
        return false;
    } // end of bindParameter
View Full Code Here

      }
    }
  }

  private DataTypeDescriptor getVarcharDescriptor() {
    return new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true);
  }
View Full Code Here

        {
          continue;
        }
        numSet++;
        ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
        DataTypeDescriptor dts = cd.getType();


        for (int i = 0; i < bulkFetchSize; i++)
        {
          // Put the column in both the compact and sparse base rows
          baseRows[i].setColumn(index + 1,
                  dts.getNull());
          compactBaseRows[i].setColumn(numSet,
                  baseRows[i].getColumn(index + 1));
        }

        // Calculate the approximate row size for the index row
        approximateRowSize += dts.getTypeId().getApproximateLengthInBytes(dts);
      }

      // Get an array of RowLocation template
      RowLocation rl[] = new RowLocation[bulkFetchSize];
      for (int i = 0; i < bulkFetchSize; i++)
View Full Code Here

    static SystemColumn getJavaColumn(String name, String javaClassName,
            boolean nullability) {

        TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName, false);

        DataTypeDescriptor dtd = new DataTypeDescriptor(typeId, nullability);
        return new SystemColumnImpl(name, dtd);
    }
View Full Code Here

   */

  public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)
    throws StandardException
  {
    DataTypeDescriptor    dtd;
    ExecRow            row;
    DataValueDescriptor    col;
    String          name = null;
    UUID          uuid = null
    UUID          suuid = null;      // schema 
View Full Code Here

    int i;
    ExecIndexRow indexRow = getIndexRowTemplate();

    for (i = 0; i < baseColumnPositions.length; i++)
    {
      DataTypeDescriptor dtd =
        columnList.elementAt(baseColumnPositions[i] - 1).getType();
      indexRow.setColumn(i + 1, dtd.getNull());
    }

    indexRow.setColumn(i + 1, rowLocation);
    return indexRow;
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.types.DataTypeDescriptor

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.