Package org.apache.derby.catalog

Examples of org.apache.derby.catalog.TypeDescriptor


        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


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

        TypeDescriptor[] columnTypes = originalMultiSet.getTypes();
        int columnCount = columnTypes.length;

        for ( int i = 0; i < columnCount; i++ )
        {
            TypeDescriptor columnType = columnTypes[ i ];

            if ( columnType.isUserDefinedType() )
            {
                DataTypeDescriptor newColumnDTD = DataTypeDescriptor.getType( columnType );

                newColumnDTD = bindUserType( newColumnDTD );

                TypeDescriptor newColumnType = newColumnDTD.getCatalogType();

                // poke the bound type back into the multi set descriptor
                columnTypes[ i ] = newColumnType;
            }
        }
View Full Code Here

    {
      throw StandardException.newException(SQLState.LANG_NO_CORRESPONDING_S_Q_L_TYPE,
        javaNode.getJavaTypeName());
    }

        TypeDescriptor catalogType = dts.getCatalogType();

        if ( catalogType.isRowMultiSet() || (catalogType.getTypeName().equals( "java.sql.ResultSet" )) )
        {
      throw StandardException.newException(SQLState.LANG_TABLE_FUNCTION_NOT_ALLOWED);
        }
       
        setType(dts);
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.BOOLEAN:
            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

             (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

        " actual is " + classInspector.getType(method));
    }
     setJavaTypeName( javaClassName );
     if (routineInfo != null)
                {
                    TypeDescriptor returnType = routineInfo.getReturnType();
                    if (returnType != null)
                    {
                        setCollationType(returnType.getCollationType());
                    }
                }
     return this;
  }
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.