Computed Fields in Firebird

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
andrevanzuydam
Zeos Dev Team
Zeos Dev Team
Posts: 32
Joined: 22.10.2005, 08:53
Location: Bloemfontein
Contact:

Computed Fields in Firebird

Post by andrevanzuydam »

I noticed that numeric computed fields which calculated correctly in Firebird were being displayed without decimals in Delphi grids. The problem seems to be that the subtype is 0 for a computed decimal field and not 1 as in all the other cases. The field type is INT64 and so wasn't working.

My work around is simple but may not be the best method of fixing this but here it is anyway.

In the TZInterbase6DatabaseMetadata.UncachedGetColumns find the following lines and add this code:

TypeName := GetIntByName('RDB$FIELD_TYPE');
SubTypeName := GetIntByName('RDB$FIELD_SUB_TYPE');
FieldScale := GetIntByName('RDB$FIELD_SCALE');
ColumnName := GetStringByName('RDB$FIELD_NAME');

//Added Code
if isNullByName('RDB$COMPUTED_SOURCE') then //AVZ
begin
//Do Nothing
end
else
begin //Computed by Source

if ((TypeName = 16) and (FieldScale < 0)) then SubTypeName := 1; // Fix for 0 subtype which removes decimals

end;

//End of Added Code

I've submitted this as a bug to the Firebird Development team as I feel that perhaps this is not really a Zeos problem but that the metadata output from Firebird is not being displayed correctly for the computed fields
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

SVN commit 605.

Mark
Image
Post Reply