Page 1 of 1

Interrogating FieldKind Property of IBCMemTable Descendant

Posted: Sat 08 Dec 2007 01:49
by SeaCay
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

Posted: Mon 10 Dec 2007 09:09
by Plash
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.

Posted: Mon 10 Dec 2007 11:21
by SeaCay
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

Posted: Mon 10 Dec 2007 11:50
by Plash
fkCalculated is used only for Delphi calculated fields. For database computed fields FieldKind must be fkData.