db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: A question about types
Date Tue, 07 Mar 2006 14:57:11 GMT
Dyre.Tjeldvoll@Sun.COM wrote:

> While working on DERBY-925 and DERBY-969, I need to get information
> about the types of the procedure/function parameters. Specifically I
> need to fill the COLUMN_DEF (Default value for the parameter, if any)
> and CHAR_OCTET_LENGTH (Byte length of char/binary types, NULL for
> other types) columns.
> So given type T, how do I
> 1) Find out if T is character or binary?
> 2) What the maximum length of T is, if char/binary?
> 3) If T has a default value?
> 4) If T's default value is NULL?
> 5) If T's value cannot be represented without truncation?
> So how can/should I use this to get the information I need? If I need
> to add information, where do I add it?

Just commenting on DERBY-925, I couldn't see how 969 related to types.

Are you baseing your work on
org.apache.derby.catalog.GetProcedureColumns, because that probably
hanldes most of the cases you require.

The javadoc for the org.apache.derby.iapi.types package may provide some

A routine is partially described by


That has methods

public TypeDescriptor[] getParameterTypes()
public public TypeDescriptor getReturnType()

TypeDescriptor represents a type in the catalogs, it's best to create an
instance of the runtime type descriptor DataTypeDescriptor from it.

TypeDescriptor td; // get from array/method

// TypeId represents the fixed aspect of a type, without
// nullability or any length attributes.
TypeId typeId = TypeId.getBuiltInTypeId(td.getJDBCTypeId());

DataTypeDescriptor dtd = new DataTypeDescriptor(typeId,
td.getPrecision(), td.getScale(), td.isNullable(), td.getMaximumWidth());

I think the above block of code should be made into a utility method in
DataTypeDescriptor, but it's not there yet.

Anyway DataTypeDescriptor has all the methods you need, some may hang
off the TypeId returned by getTypeId.

Function parameters and return types do not have defaults.

Not sure about the truncation question, what's doing the truncation,
what do you mean value of T?

Hope this helps,

View raw message