begin;

create temp table data_type (code integer, desc varchar(255), fixed integer);
insert into data_type values (0, 'char', 0);
insert into data_type values (1, 'smallint', 1);
insert into data_type values (2, 'integer', 1);
insert into data_type values (3, 'float', 1);
insert into data_type values (4, 'smallfloat', 1);
insert into data_type values (5, 'decimal', 0);
insert into data_type values (6, 'serial', 0);
insert into data_type values (7, 'date', 1);
insert into data_type values (8, 'money', 0);
insert into data_type values (9, 'null', 0);
insert into data_type values (10, 'datetime', 0);
insert into data_type values (11, 'byte', 0);
insert into data_type values (12, 'text', 0);
insert into data_type values (13, 'varchar', 0);
insert into data_type values (14, 'interval', 0);
insert into data_type values (15, 'nchar', 0);
insert into data_type values (16, 'nvarchar', 0);
insert into data_type values (17, 'int8', 0);
insert into data_type values (18, 'serial8', 0);


select a.tabname, b.colno, b.colname, case c.fixed when 1 then c.desc else c.desc || '(' || b.collength || ')' end
  from systables a, syscolumns b, data_type c
where a.owner = 'baandb'
    and a.tabname like 'ttdilc301213'
    and b.tabid = a.tabid 
    and not (b.colname like 'hash%' or b.colname like 't_refcnt%')
    and c.code = b.coltype - 256
order by a.tabname, b.colno;

rollback;