Subject RE: [ib-support] Re: extract metadata problem
Author Martijn Tonies
Hi Bram,

>Thanks Martijn, I just want to extract fieldname, type + lenght from
>a table in a database and not depending on a component. Should this
>really be so difficult ???

NUMERIC/DECIMAL -> are stored as SMALLINT, INTEGER or INT64, depending
on their precision/scale factor. With IB5, you do not know if the
column/domain was defined as NUMERIC or DECIMAL. With IB6, check
RDB$FIELD_SUBTYPE. You also don't know the field _exact_ precision in
IB5, for IB6, check RDB$FIELD_PRECISION...

Don't trust RDB$TYPES ... several types are missing - rather translate
the values to types yourself.

Length comes from different columns -- there's RDB$CHARACTER_LENGTH that
show the character length for (var)char columns while RDB$FIELD_LENGTH I
believe lists the length in bytes. RDB$FIELD_SCALE holds the scale
factor (negative value).

Some field properties can be overridden in RDB$RELATION_FIELDS, some

(all from the top of my head, so there might be some errors)

Hope this helps,

Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird

--- In ib-support@y..., "Martijn Tonies" <martijn@b...> wrote:
> Bram,
> take your time to read through the Language Reference chapter System
> Tables and Views. Also take time to read the Data Definition Guide
> you will see that both NUMERIC and DECIMAL aren't stored as such.
> Extracting detailed metadata information is an error prone task -
> gets it right the first, second and third time.
> Depending on what you actually want, why don't you use existing
> IBX, IBO and probably FIBPlus all have their metadata extract
> components. Heck, even browsing the IBConsole code at SourceForge
> get you going.
> Martijn Tonies
> InterBase Workbench - the developer tool for InterBase and Firebird
> With the following sql, fieldtype: nummeric, lenght: 18, scale: 2
> not shown. Any idea why?
> Thanks Bram
> select
> r.rdb$relation_name as tablename,
> r.rdb$field_name as fieldname,
> t.rdb$type_name as typename,
> f.rdb$field_length as fieldlength, r.RDB$FIELD_SOURCE AS
> from
> rdb$relation_fields r, rdb$types t, rdb$fields f
> where
> r.rdb$relation_name='MATFAC' and
> r.rdb$relation_name not like 'RDB%' and
> f.rdb$field_name=r.rdb$field_source and
> t.rdb$field_name='RDB$FIELD_TYPE' and
> f.rdb$field_type=t.rdb$type
> order by
> r.rdb$relation_name

Yahoo! Groups Sponsor

To unsubscribe from this group, send an email to:

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.