Probably an INTEGER or a BIGINT that is NULLable. For convenience, you

might use the LENGTH function to calculate the length of such objects,

and use a standard data type that can handle any possible value returned.

Example:

select length(col1), length(col2), length(col3), length(col4) from

testdec

1 2 3 4

----------- ----------- ----------- -----------

13 13 9 9

1 record(s) selected.

Details of the LENGTH function from the SQL Reference manual:

"The LENGTH function returns the length of a value.

The argument can be an expression that returns a value of any built-in

data type.

The result of the function is a large integer. If the argument can be

null, the result can be null; if the argument is null, the result is the

null value.

The result is the length of the argument. The length does not include

the null indicator byte of column arguments that allow null values. The

length of strings includes blanks but does not include the length

control field of varying-length strings. The length of a varying-length

string is the actual length, not the maximum length.

The length of a graphic string is the number of DBCS characters. The

length of all other values is the number of bytes used to represent the

value:

2 for small integer

4 for large integer

(p/2)+1 for decimal numbers with precision p

The length of the string for binary strings

The length of the string for character strings

4 for single-precision floating-point

8 for double-precision floating-point

4 for date

3 for time

10 for timestamp"

Pekka Henttonen wrote:

Forgive me this stupid question, but what is the best way to store the

length of an object in a database? What datatype would you use? Would

it be better to define one of your own?