Home DADE
New Blog Posts: Merging Reports - Part 1 and Part 2

Dictionary Changes

edited September 2012 in DADE
If I've changed the field aliases in a Dictionary, but I have lots of
report that are already written using the old field aliases, can I do
something at runtime in the that will force everything to refresh (I
don't want to untick all fields and then re-tick as this breaks links
between dataviews etc)?

As a temp test I've re-assigned the Close click on the File menu for the
Data tab to do:

lDataModule := daGetDataModule(Report);

if assigned(lDataModule) then
begin
gMetaDataManager.Clear;

for I := 0 to lDataModule.DataViewCount - 1 do
begin
lDataModule.DataViews[i].OutOfSync;
lDataModule.DataViews[i].Sync;
end;

end;

...but it doesn't work :)

Any suggestions?

TIA Paul

Comments

  • edited September 2012
    I worked it out myself. I would be grateful if anyone could point out
    anything I've missed or anything I'm doing that's not necessary:

    procedure TnxRBDesignerEngine.DoDataModuleFieldsRefresh(Sender : TObject);
    var
    lDataModule : TdaDataModule;
    i : Integer;
    lSQL : TdaSQL;
    lSQLBuilder : TdaSQLBuilder;
    lDataView : TdanxQueryDataView;
    begin

    {get the datamodule}
    lDataModule := daGetDataModule(Report);

    if assigned(lDataModule) then
    begin

    for I := 0 to lDataModule.DataViewCount - 1 do
    begin
    lDataView := TdanxQueryDataView(lDataModule.DataViews[i]);

    lDataView.Sync;

    lSQL := lDataView.SQL;

    lSQLBuilder := TdaSQLBuilder.Create(lSQL);

    lSQLBuilder.SelectFields.Clear;
    lSQLBuilder.SelectFields.AddAllFields;

    lSQLBuilder.free;
    end;

    end;

    end;


  • edited September 2012
    Actaully, it "almost" works: when the DataViews update themselves the
    SIZE column for every field is set to 10! If I just popup the
    QueryDesigner and close it (OK btn) then this gets corrected. Any
    suggestions?


    P.S. Core code refined to the following:


    lDataView := TdanxQueryDataView(lDataModule.DataViews[i]);

    lSQL := lDataView.SQL;

    lSQLBuilder := TdaSQLBuilder.Create(lSQL);

    lSQLBuilder.SelectFields.AddAllFields;

    lSQLBuilder.ApplyUpdates;

    lSQLBuilder.free;

  • edited September 2012
    Hi Paul,

    Try calling SQL.Valid before making the call to ApplyUpdates. This will
    refresh the field lengths before assigning the SQL object.

    ...

    lSQLBuilder.SQL.Valid;

    lSQLBuilder.ApplyUpdates;

    ...

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2012
    Thanks Nico - that works a treat!

This discussion has been closed.