Subject Re: Access Table Column Metadata
Author Tom Conlon
Hi Myles,

> How can I query the Firebird database (this is in 1.5)
> and get back the column names and field types,
> so I can validate the text file for the import?


How to get the column/domain data for 1 table
---------------------------------------------
SELECT RF.RDB$FIELD_NAME AS FieldName,
CASE
WHEN T.RDB$TYPE_NAME = 'VARYING' THEN 'VARCHAR'
WHEN T.RDB$TYPE_NAME = 'TEXT' THEN 'CHAR'
WHEN T.RDB$TYPE_NAME = 'INT64' THEN 'BIGINT'
WHEN T.RDB$TYPE_NAME = 'LONG' THEN 'INTEGER'
ELSE
T.RDB$TYPE_NAME
END AS fldtype,
RF.RDB$FIELD_SOURCE AS DOMNAME,
F.RDB$FIELD_LENGTH AS FieldLength,
RF.RDB$NULL_FLAG AS AllowNulls,
CS.RDB$DEFAULT_COLLATE_NAME AS CharacterSet,
RF.RDB$DEFAULT_SOURCE AS DefaultValue,
F.RDB$COMPUTED_SOURCE AS ComputedSource,
F.RDB$FIELD_SUB_TYPE AS SubType,
F.RDB$FIELD_PRECISION AS FieldPrecision
FROM RDB$RELATION_FIELDS RF
LEFT JOIN RDB$FIELDS F ON (F.RDB$FIELD_NAME = RF.RDB$FIELD_SOURCE)
LEFT JOIN RDB$TYPES T ON (T.RDB$TYPE = F.RDB$FIELD_TYPE)
LEFT JOIN RDB$CHARACTER_SETS CS ON (CS.RDB$CHARACTER_SET_ID =
F.RDB$CHARACTER_SET_ID)
WHERE T.RDB$FIELD_NAME = 'RDB$FIELD_TYPE' AND RF.RDB$RELATION_NAME =
'EMPLOYEE'
ORDER BY RF.RDB$FIELD_POSITION;


HTH,
Tom