Interrogating FieldKind Property of IBCMemTable Descendant

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
SeaCay
Posts: 26
Joined: Wed 10 Jan 2007 03:03

Interrogating FieldKind Property of IBCMemTable Descendant

Post by SeaCay » Sat 08 Dec 2007 01:49

Hi CRLabs

A code snippet

Code: Select all

 isDataField := IBCQuery1.FieldByName('CALCFIELD1').fieldKind
returns fkData when it should return fkCalculated for a Calculated field.

Is this a bug and if so is there a work-around.

Also I suspect that fkLookup, fkInternalCalc and fkAggregate may not also be correctly returned but I have not tested this yet as my production code only referes to fkCalculated field.

regards

SeaCay

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 10 Dec 2007 09:09

Please see value of FieldKind property for CALCFIELD1 field in Object Inspector. If it is set to fkData, change it to fkCalculated. Also please check what FieldKind is set for newly created calculated fields.

SeaCay
Posts: 26
Joined: Wed 10 Jan 2007 03:03

Post by SeaCay » Mon 10 Dec 2007 11:21

Hi

My apologies, I should have said that CALCFIELD1 is a calculated, persistant field in a FireBird database and is not dynamically created in code. The DDL definition for CALCFIELD1 is

Code: Select all

CALCFIELD1 COMPUTED BY ((EXTRACT(MONTH FROM SOMEDATE))),
IBCQuery1 has an SQL property of

Code: Select all

SELECT DISTINCT SOMEDATE,
       CALCFIELD1,
       CALCFIELD2
    FROM SOMETABLE
  WHERE
    SOMEDATE BETWEEN '2007/10/1' AND '2007/10/31'
ORDER BY SOMEDATE
If I attempt what you have asked in setting the FieldKind property at runtime I get the error:
IBCQuery1: Cannot perform this operation on an open dataset.
The reason why I have raised this question is that IBX components correctly return the FieldKind property for CALCFIELD1 and CALCFIELD2 as fkCalculated

regards and thanks

SeaCay

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 10 Dec 2007 11:50

fkCalculated is used only for Delphi calculated fields. For database computed fields FieldKind must be fkData.

Post Reply