Subject RE: [IBO] TIBOQuery - where to create dynamic TFields?
Author Roger Vellacott
TIBOQuery has the property "InternalDataset", which gives the
functionality of TIB_ components. I find it much easier to control than
dynamically created TFields, but maybe it's just a matter of taste.

Roger Vellacott
Passfield Data Systems Ltd

-----Original Message-----
From: G. Nau [mailto:b404_r66@...]
Sent: 11 June 2007 07:34
Subject: RE: [IBO] TIBOQuery - where to create dynamic TFields?

Roger, thanks for the reply.
But I'm using TDataset compatible TIBOQuery, not the native IBO ones,
fast report.
So the definition of the calculated fields is different but already
procedure TLagerDrucken.IBOQuery_MainCalcFields(DataSet: TDataSet);
With IBOQuery_Main do

My problem is creating at least ONE calculated Tfield in the query and
lossing ALL the default fields of the query. That's default TDataset
and not IBO specific.
I need the default fields for the query auto-generated. The SQL of the
is dynamic, so I can't define the fields statically.
Then I have to add some calculated tfields. And that's the point where
stuck at the moment and need some help.

Am 10 Jun 2007 um 21:48 hat Roger Vellacott geschrieben:

> A much better way is to add calculated fields to the TIBOQuery
> component. You can do this on the component, or in code.
> //Somewhere in the initialisation code, or in form create.
> with MyQuery.InternalDataset, CalculatedFields do
> begin
> Clear;
> Add('CALC_FIELD_1 VARCHAR(20)');
> Add(CALC_FIELD_2 DECIMAL(18,4)');
> OnCalculateField := MyQueryCalculateField;
> end;
> procedure TMyForm.MyQueryCalculateField((Sender: TIB_Statement;
> ARow: TIB_Row; AField: TIB_Column);
> begin
> if AField.FieldName = 'CALC_FIELD_1' then
> begin
> AField.Value := ARow..ByName('FIELD_1').Value *
> ARow.ByName('FIELD_2').Value;
> end
> else if AField.FieldName = 'CALC_FIELD_2' then
> begin
> //some other calculation
> end;
> end;
> When referring to the current table (MyQuery) be careful to use ARow.
> The values of fields in MyQuery may not have been updated to the
> current record when the calculation takes place.
> Roger Vellacott
> -----Original Message-----
> From: G. Nau [mailto: b404_r66@yahoo. <> de]
> Sent: 10 June 2007 20:26
> To: iBObjects@yahoogrou <>
> Subject: [IBO] TIBOQuery - where to create dynamic TFields?
> I'm using IBO 4.7/FB2.0 with FastReport 4.1x and IBOs TDataset
> compatible components.
> It's working fine, but for some reasons I can not use the
> TDataset-fieldeditor
> to define additional calculated field.
> I'd like to create dynamic tfields for the TIBOQuery using this code
> fragment:
> Procedure TLagerDrucken.Addfields;
> VAR vkbrutto: tcurrencyfield;
> begin
> inherited;
> vkbrutto:=TCurrencyField.Create(IBOQuery_Main);
> with vkbrutto do
> Begin
> FieldKind:=fkCalculated;
> fieldname:='vkbrutto';
> calculated:=True;
> DataSet:=IBOQuery_Main;
> end;
> But which event do I have to use to add these fields?
> The only event Fastreport is triggering going into the report designer
> is the
> onprepare event. Adding my AddFields here is adding my field but then
> I'm
> missing all the default fields.
> That's of course TDataset default behaviour:
> -leave the Fieldeditor empty and TDataset is creating all fields from
> the
> query automatically
> -want to use additional fields? Then use the field editor, but in this
> case
> you'll have to add ALL field to the query, too. That's bad, when the
> query
> itself is dynamic.
> Any idea to get ALL fields of the query AND add some calculated ones?
> Regards
> Gunther
> __________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
> without the need for BDE, ODBC or any other layer.
> __________________________________________________________
> http://www.ibobject <> - your IBO
community resource for Tech Info papers,
> keyword-searchable FAQ, community code contributions and more !
> Yahoo! Groups Links