Hello,
I added this code in the BeforeOpen event of my TSmartQuery. The field was created, but the TSmartQuery did not create fields for any of columns of the query. Is there a way to add Calculated Fields in TSmartQuery?
Thanks,
John D.
Field := TIntegerField.Create(qrydata);
Field.FieldName := 'RecNo';
Field.Calculated := True;
Field.Dataset := qrydata;
qryData.OnCalcFields := DataSetCalcFields;
Calculated fields
You should create data fields first. Use the following code to create data fields:
Code: Select all
OraQuery1.FieldDefs.Update;
// copied from DB unit
if OraQuery1.ObjectView then
begin
for I := 0 to OraQuery1.FieldDefs.Count - 1 do
with OraQuery1.FieldDefs[I] do
if (DataType ftUnknown) and
not ((faHiddenCol in Attributes) and not OraQuery1.FIeldDefs.HiddenFields) then
CreateField(Self);
end else
begin
for I := 0 to OraQuery1.FieldDefList.Count - 1 do
with OraQuery1.FieldDefList[I] do
if (DataType ftUnknown) and not (DataType in ObjectFieldTypes) and
not ((faHiddenCol in Attributes) and not OraQuery1.FIeldDefs.HiddenFields) then
CreateField(Self, nil, OraQuery1.FieldDefList.Strings[I]);
end;