Package org.apache.derby.catalog

Examples of org.apache.derby.catalog.TypeDescriptor


   *
   * @return true if it has a parameter or return type of character string
   */
  private boolean anyStringTypeDescriptor() {
    RoutineAliasInfo rai = (RoutineAliasInfo)aliasInfo;
    TypeDescriptor aType = rai.getReturnType();
    TypeId compTypeId;
    /*
    ** Try for a built in type matching the
    ** type name. 
    */
    if (aType != null) //that means we are not dealing with a procedure
    {
      compTypeId = TypeId.getBuiltInTypeId(aType.getTypeName());
      if (compTypeId != null && compTypeId.isStringTypeId())
        return true;     
    }
    if (rai.getParameterCount() != 0) {
      int paramCount = rai.getParameterCount();
View Full Code Here


        if ( parameterTypes == null ) { return; }

        int count = parameterTypes.length;
        for ( int i = 0; i < count; i++ )
        {
            TypeDescriptor td = parameterTypes[ i ];

            // if this is a user defined type, resolve the Java class name
            if ( td.isUserDefinedType() )
            {
                DataTypeDescriptor dtd = DataTypeDescriptor.getType( td );

                dtd = bindUserType( dtd );
                parameterTypes[ i ] = dtd.getCatalogType();
View Full Code Here

    if (routineInfo != null)
    {
      if (methodParms != null)
        optimizeDomainValueConversion();
     
      TypeDescriptor returnType = routineInfo.getReturnType();

            // create type dependency if return type is an ANSI UDT
            if ( returnType != null ) { createTypeDependency( DataTypeDescriptor.getType( returnType ) ); }

      if ( returnType != null && !returnType.isRowMultiSet() && !returnType.isUserDefinedType() )
      {
        TypeId returnTypeId = TypeId.getBuiltInTypeId(returnType.getJDBCTypeId());

        if (returnTypeId.variableLength()) {
          // Cast the return using a cast node, but have to go
          // into the SQL domain, and back to the Java domain.

          DataTypeDescriptor returnValueDtd = new DataTypeDescriptor(
                returnTypeId,
                returnType.getPrecision(),
                returnType.getScale(),
                returnType.isNullable(),
                returnType.getMaximumWidth()
              );
             

          ValueNode returnValueToSQL = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
                this,
                getContextManager());

          ValueNode returnValueCastNode = (ValueNode) getNodeFactory().getNode(
                  C_NodeTypes.CAST_NODE,
                  returnValueToSQL,
                  returnValueDtd,
                  getContextManager());
                   
                    // DERBY-2972  Match the collation of the RoutineAliasInfo
                    returnValueCastNode.setCollationInfo(
                            returnType.getCollationType(),
                            StringDataValue.COLLATION_DERIVATION_IMPLICIT);


          JavaValueNode returnValueToJava = (JavaValueNode) getNodeFactory().getNode(
                    C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
                    returnValueCastNode,
                    getContextManager());
          returnValueToJava.setCollationType(returnType.getCollationType());
          return returnValueToJava.bindExpression(fromList, subqueryList, aggregateVector);
        }

      }
    }
View Full Code Here

      signature = new JSQLType[sigParameterCount];
      for (int p = 0; p < parameterCount; p++) {

        // find the declared type.

        TypeDescriptor td = parameterTypes[p];

        TypeId typeId = TypeId.getTypeId(td);

        TypeId parameterTypeId = typeId;


        // if it's an OUT or INOUT parameter we need an array.
        int parameterMode = routineInfo.getParameterModes()[p];

        if (parameterMode != JDBC30Translation.PARAMETER_MODE_IN) {

          String arrayType;
          switch (typeId.getJDBCTypeId()) {
            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.REAL:
            case java.sql.Types.DOUBLE:
              arrayType = getTypeCompiler(typeId).getCorrespondingPrimitiveTypeName().concat("[]");
              break;
            default:
              arrayType = typeId.getCorrespondingJavaTypeName().concat("[]");
              break;
          }

          typeId = TypeId.getUserDefinedTypeId(arrayType, false);
        }

        // this is the type descriptor of the require method parameter
        DataTypeDescriptor methoddtd = new DataTypeDescriptor(
            typeId,
            td.getPrecision(),
            td.getScale(),
            td.isNullable(),
            td.getMaximumWidth()
          );

        signature[p] = new JSQLType(methoddtd);

        // check parameter is a ? node for INOUT and OUT parameters.

        ValueNode sqlParamNode = null;

        if (methodParms[p] instanceof SQLToJavaValueNode) {
          SQLToJavaValueNode sql2j = (SQLToJavaValueNode) methodParms[p];
          sqlParamNode = sql2j.getSQLValueNode();
        }
        else
        {
        }

        boolean isParameterMarker = true;
        if ((sqlParamNode == null) || !sqlParamNode.requiresTypeFromContext())
        {
          if (parameterMode != JDBC30Translation.PARAMETER_MODE_IN) {
          
            throw StandardException.newException(SQLState.LANG_DB2_PARAMETER_NEEDS_MARKER,
              RoutineAliasInfo.parameterMode(parameterMode),
              routineInfo.getParameterNames()[p]);
          }
          isParameterMarker = false;
        }
        else
        {
          if (applicationParameterNumbers == null)
            applicationParameterNumbers = new int[parameterCount];
            if (sqlParamNode instanceof UnaryOperatorNode) {
              ParameterNode pn = ((UnaryOperatorNode)sqlParamNode).getParameterOperand();
              applicationParameterNumbers[p] = pn.getParameterNumber();
            } else
            applicationParameterNumbers[p] = ((ParameterNode) sqlParamNode).getParameterNumber();
        }

        // this is the SQL type of the procedure parameter.
        DataTypeDescriptor paramdtd = new DataTypeDescriptor(
          parameterTypeId,
          td.getPrecision(),
          td.getScale(),
          td.isNullable(),
          td.getMaximumWidth()
        );

        boolean needCast = false;
        if (!isParameterMarker)
        {
View Full Code Here

     */
    public DataTypeDescriptor getDataType() throws StandardException
    {
        if ( routineInfo != null )
        {
            TypeDescriptor td = routineInfo.getReturnType();

            if ( td != null ) { return DataTypeDescriptor.getType( td ); }
        }

        return super.getDataType();
View Full Code Here

             (List) null,
             true,
             TransactionController.ISOLATION_REPEATABLE_READ,
             tc);
        RoutineAliasInfo   oldRai = (RoutineAliasInfo) oldAD.getAliasInfo();
        TypeDescriptor     newReturnType = DataTypeDescriptor.getCatalogType( Types.VARCHAR, LOBStoredProcedure.MAX_CLOB_RETURN_LEN );
        RoutineAliasInfo   newRai = new RoutineAliasInfo
            (
             oldRai.getMethodName(),
             oldRai.getParameterCount(),
             oldRai.getParameterNames(),
View Full Code Here

       
        AliasDescriptor ad = DataDictionaryImpl.SYSFUN_AD[f];
        if (ad == null)
        {
          // details[1] Return type
          TypeDescriptor rt =
            DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]).getCatalogType();

                    boolean isDeterministic = Boolean.valueOf( details[ SYSFUN_DETERMINISTIC_INDEX ] ).booleanValue();
                   
                    // Determine the number of arguments (could be zero).
View Full Code Here

    private final void create_SYSCS_procedures(
                                               TransactionController   tc, HashSet newlyCreatedRoutines )
        throws StandardException
    {
        // Types used for routine parameters and return types, all nullable.
        TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(
                Types.VARCHAR, 32672);

        /*
    ** SYSCS_UTIL routines.
    */
 
View Full Code Here

  7 - Boolean - CALLED ON NULL INPUT
  8 - TypeDescriptor - return type
*/
  final public StatementNode functionDefinition() throws ParseException, StandardException {
        TableName functionName;
        TypeDescriptor  returnType;
        Object[] functionElements = new Object[CreateAliasNode.ROUTINE_ELEMENT_COUNT];
    jj_consume_token(FUNCTION);
    functionName = qualifiedName(Limits.MAX_IDENTIFIER_LENGTH);
    functionElements[0] = functionParameterList();
    jj_consume_token(RETURNS);
    returnType = functionReturnDataType();
    label_35:
    while (true) {
      routineElement(false, returnType.isRowMultiSet(), functionElements);
      switch (jj_nt.kind) {
      case EXTERNAL:
      case NO:
      case NOT:
      case CALLED:
View Full Code Here

/*
* <A NAME="functionReturnDataType">functionReturnDataType</A>
*/
  final public TypeDescriptor functionReturnDataType() throws ParseException, StandardException {
    TypeDescriptor      typeDescriptor;
    if (jj_2_70(1)) {
      typeDescriptor = catalogType();
    } else {
      switch (jj_nt.kind) {
      case TABLE:
View Full Code Here

TOP

Related Classes of org.apache.derby.catalog.TypeDescriptor

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.