add pipeline at runtime

we need to generate some ppDBPipeline at runtime and connect to relative subreport
We generate different pipelines, with different queries and we need those visible at runtime.
Naturally our system open corect report for different pipelines...


LQ := TMyQuery_go.Create(nil);
LQ.Connection := arc.arcsor;
LQ.SQL.Text := 'SELECT * FROM myperfix_' + username + '_' + ATableName + ' ;';

LQ_ds := TDataSource.Create(nil);
LQ_ds.DataSet := LQ;

LDBPipeline.AutoCreateFields := True;
LDBPipeline.DataSource := LQ_ds;
LDBPipeline.UserName := 'u' + ATableName;

FppQuery.Add(LQ);
FppDs.Add(LQ_ds);
FppDBTable.Add(LDBPipeline);

why when we open the report pipelines are not visible?
We can only see pipelines create with a component on the form

Fabio
P-Soft





Fabio Codebue
P-Soft
web: https://www.p-soft.biz
Firebird Foundation Commitee Member

Comments

  • Hi Fabio,

    - The Report and DataPipelines should have the same Owner. The Owner is typically a Form or DataModule.

    example: myDBPipeline := TppDBPipeline.Create(myReport.Owner)

    - Create the DataPipelines first, then load the report template

    - When using the Designer you can position the cursor above the Data Tree tool window, press right mouse and select Refresh from the context menu. This will rebuild the data pipeline list.

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • thanks Nard, infact now I can see pipelines in report.
    I use this code

    LQ := TMyQuery_go.Create(nil);
    LQ.Connection := arc.arcsor;
    LQ.SQL.Text := 'SELECT * FROM ' + ATableName + ' ;';

    LQ_ds := TDataSource.Create(nil);
    LQ_ds.DataSet := LQ;

    LDBPipeline.AutoCreateFields := True;
    LDBPipeline.DataSource := LQ_ds;
    LDBPipeline.UserName := 'DB' + ATableName;
    { define the master/detail pipeline relationship }
    LDBPipeline.MasterDataPipeline := ppDBTabella;
    { create a new field link }
    LFieldLink := TppMasterFieldLink.Create(nil);
    LFieldLink.Parent := LDBPipeline;
    { assign the detail field name }
    LFieldLink.DetailFieldName := 'detailMasterPK';
    { assign the master field name }
    LFieldLink.MasterFieldName := 'masterPK';

    but it generates thousands of pages... with an infinite loop ...
    I have 1 record in master table and 2 records in detail table

    Fabio
    P-Soft

    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
  • Hi Fabio,

    - RB supports two types of linking, here's a link to an rbWiki article with details. For DataPipeline linking the detail data must be ordered by the linking field(s)

    http://rbwiki.digital-metaphors.com/data-access/database/linking-sql-queries/

    - This rbWiki article includes an example of create the DBPipeline FieldLinks in code

    http://rbwiki.digital-metaphors.com/data-access/fundamentals-data-access/define-masterfieldlinks-in-code/

    - Make sure the Report.DataPipeline is assigned to the master and the Subreport.DataPipeline is assigned to the detail DBPipeline.

    I don't know what your exact requirements are, but another approach is to use the RB Data workspace (DADE). This rbWiki article details how to create query data views via code

    http://rbwiki.digital-metaphors.com/dade/program-control/how-to-create-query-dataviews-via-code/'




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • I read these info but I didn't find what I really need.
    I create several pipeline at runtime.
    I prepare specific report that contains subreports.
    I need to loop for all subreports into report to identify them and connect correct pipeline that I created at runtime
    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
  • Hi Fabio,

    Create a TStringList and call Report.GetSubReports(aReportList: TStrings). The caption is the string and the TppChildReport is the aReportList.Objects[ ] property. This method returns all nested ChildReports.



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
Sign In or Register to comment.