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

TdaSqlBuilder in Master-Detail mode does not work...

edited January 2006 in RAP
Hi

Does anyone have a simple rtm-example how to program a master-detail
relation using the TdaSqlBuilder-Object in RAP?
My report has a supreport with the detaildata on it. Every time the
masterrecord change the subreport should display the detaildata.

I tried to do that but the ApplyUpdates does not fire any refetch of data.

Thanks and best regards
Robert


Here my code:

// this is the initial code for the detail pipeline
procedure ReportBeforeOpenDataPipelines;
var lSQLBuilder : TdaSQLBuilder;
begin
lSQLBuilder := TdaSQLBuilder.Create(ppVGK_AKTIVITAETEN);
lSQLBuilder.Clear;
lSQLBuilder.SelectTables.Add('VGK_AKTIVITAETEN');
lSQLBuilder.SelectFields.AddAllFields;
lSQLBuilder.SearchCriteria.Add('VGK_AKTIVITAETEN', 'GELFNR', '=', '0');
lSQLBuilder.ApplyUpdates;
lSQLBuilder.Free;
end;

// this is the code using for the supreport-data
procedure SubReport1OnPrint;
var lSQLBuilder : TdaSQLBuilder;
begin
lSQLBuilder := TdaSQLBuilder.Create(ppVGK_AKTIVITAETEN);
lSQLBuilder.SearchCriteria[0].Value := Pipe['GELFNR'];
<< on this 'GELFNR' the data should be fetched, but nothing happend
lSQLBuilder.ApplyUpdates;
lSQLBuilder.Free;
end;

Comments

  • edited January 2006

    There is no way to control the detail SQL for each master record, that is
    not how the Data workspace linking is implemented. The Data workspace linkes
    the datapipelines and generates special linking SQL for the detail dataview.
    This results in a single detail SQL statement. Please see the article
    below...

    TdaSQLBuilder can only be used from an event of the main report that occurs
    prior to the datapipelines being opened. I recommend using the
    Report.BeforeOpenDataPipelines event.


    -------------------------------------------
    Tech Tip: Linking DataViews
    -------------------------------------------

    Overview
    ---------

    Linking DataViews in the ReportBuilder Data workspace (DADE), requires that
    the detail data be sorted by the linking fields. When DataViews are linked,
    DADE generates special linking SQL for the detail DataView. The linking SQL
    (Magic SQL) can be viewed by positioning the mouse over the DataView window
    and pressing Ctrl + Left Mouse button. The results of the Magic SQL query
    can be viewed by pressing Shift + Left Mouse button.

    ReportBuilder's DataPipeline architecture includes support for linked data
    traversal. Whenver the record position of the master data changes, the
    traversal logic compares the master and detail field link values and then
    determines where to locate the record position for the related detail data.
    The linking logic will only work properly if the Database engine's collation
    of the detail query result set is in sync with ReportBuilder's internaly
    field link comparison logic.





    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.