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

Converting existing reports when database fields and tables change...

edited July 2002 in General
Hi,

Has anyone had any experience updating saved reports (RTM files) to match
their database after making changes such as moving fields from one table to
another, and deleting old tables that are not used any more (because the
fields have moved to another table).

I'd appreciate hearing any tips or seeing any code that anyone may have used
in this regard.

Sincererly,
Vinnie Murdico

Comments

  • edited July 2002
    If not using DADE, how about using your queries with aliases for the field names
    (You'll have to change the queries anyway)? In that way you shouldn't have to
    change nothing on the reports.

    SELECT
    Field1 as OldField1Value
    FROM
    etc....

  • edited July 2002
    If you actually want to write a conversion utility you can simply iterate
    through your reports and then iterate through all the object in the report
    using the loop below.

    procedure UpdateReport(aReport: TppReport)'

    for (liBands := 0 to aReport1.BandCount - 1) do
    for (liObjects := 0 to aReport1.Bands[liBands].ObjectCount - 1) do
    begin
    lObject := aReport1.Bands[liBands].Objects[liObject];
    if (lObject is TppSubreport) then
    UpdateReport(TppSubreport(aReport).Report)
    else if (lObject is TppComponent) then
    begin
    lComponent := TppComponent(lObject);
    if lComponent.IsDataAware
    // update lComponent.DataPipeline and lComponent.DataField
    end;
    end;

    The other option is to parse through the RTMs themselves updating occurences
    of 'DataField' and 'DataPipeline'. For example:

    for all templates
    begin
    lStream := TFileStream.Create('aTemplate', fmOpenRead);
    while not end of stream do
    begin
    liIndex := Pos('DataField');
    if (liIndex := -1) then
    begin
    // replace data field name
    liIndex := Pos('DataPipeline') then
    // replace data pipeline name
    end;
    end;
    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.