community.borland.com

Article #25527: Computing the length of a table's row

Problem:
How do I compute the length of a row?

Solution:


Here is a query that will print the length of a row.  
This examples uses the EMPLOYEE table from the employee.gdb 
that ships with InterBase.  You must change the tablename
to the table in which you want to compute the row length.

select  sum(f.rdb$field_length)
from    rdb$relation_fields r, rdb$types t, rdb$fields f 
where   r.rdb$relation_name='EMPLOYEE' 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; 

Here is a stored procedure that will accomplish the same thing.
You must create this procedure in your database and pass in
the name of the table that you are interested in.

create procedure getrowlength (tablename char(32))
returns (rowlength integer)
as
begin
  select  sum(f.rdb$field_length)
  from    rdb$relation_fields r, rdb$types t, rdb$fields f 
  where   r.rdb$relation_name=upper(:tablename) 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 
  into :rowlength;
end!!


Last Modified: 26-OCT-00