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 =
new JavaToSQLValueNode(this, getContextManager());
ValueNode returnValueCastNode = new CastNode(
returnValueToSQL,
returnValueDtd,
getContextManager());
// DERBY-2972 Match the collation of the RoutineAliasInfo
returnValueCastNode.setCollationInfo(
returnType.getCollationType(),
StringDataValue.COLLATION_DERIVATION_IMPLICIT);
JavaValueNode returnValueToJava = new SQLToJavaValueNode(
returnValueCastNode, getContextManager());
returnValueToJava.setCollationType(returnType.getCollationType());
return returnValueToJava.bindExpression(fromList, subqueryList, aggregates);
}
}
}