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

How to execute a SQL Sentence from ReportBuilder?

edited March 2005 in End User
I need to execute a SQL Sentence from ReportBuilder, how to do that?

Thanks in advance

Comments

  • edited March 2005
    Hi Miguel,

    I am a bit unclear about what you would like to do from ReportBuilder. If
    you have the Professional edition of ReportBuilder or above, you can execute
    your own custom queries without the need to access a TDataSet descendent in
    Delphi. This can be done in the data workspace of the designer (data tab).
    Also, if you would like to filter your existing data from inside your
    report, you can use the AutoSearch feature.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2005
    hi, i have a similar question... i have a rtm on end user... i need to
    attach another query adding a where clause for filtering some data... what
    can do??



    Simone
  • edited March 2005
    Hi Simone,

    If you would like to add a new query to your template (in DADE), you will
    need to create a new DataView in code (preferably in the Template.OnLoadEnd
    event). If you would like to link an existing query in with your report,
    you will need to do this in code as well by assigning the
    Report.Datapipeline property in the same event. See the following article
    for more information.

    -------------------------------------------------------
    Tech Tip: Creating a DataView in Code
    -------------------------------------------------------


    uses
    daDatMod, daQClass, daDataVw, daQuery, daDBBDE;



    {------------------------------------------------------------------------------}
    {TForm1.CreateDataView}

    procedure TDynamicReport.CreateDataView;
    var
    lSQL: TdaSQL;
    lTable: TdaTable;
    lField: TdaField;

    begin

    {create a datamodule - note: this is only necessary if you
    need to stream the report definition to an .rtm or database}
    FDataModule := TdaDataModule.CreateForReport(FReport);

    {create a query dataview}
    FDataView := TdaBDEQueryDataView.Create(Self);
    FDataView.Parent := FDataModule;

    {initialize the dataview}
    FDataView.Init;

    {define database connect and type}
    FDataView.SQL.DatabaseName := 'DBDemos';
    FDataView.SQL.DatabaseType := dtParadox;
    FDataView.SQL.SQLType := sqBDELocal;
    FDataView.SQL.Session := FDataView.Session;

    {create local version of the SQL object}
    lSQL := TdaSQL.Create(Self);
    lSQL.Assign(FDataView.SQL);

    {modify the local version}
    { lSQL.SQLText.Text := 'Select * from clients';
    lSQL.EditSQLAsText := True;
    }

    lTable := lSQL.AddTable('clients');
    lSQL.AddSelectField(lTable, 'Last_Name');
    lSQL.AddSelectField(lTable, 'First_Name');


    {assign local SQL object values to the dataview}
    FDataView.SQL := lSQL;

    {get a reference to the dataivew's pipeline and assign a Name to the
    pipeline}
    FPipeline := TppDBPipeline(FDataView.DataPipelines[0]);
    FPipeline.Name := 'plClient';

    {connect report to datapipeline}
    FReport.DataPipeline := FPipeline;

    lSQL.Free;

    end; {procedure, CreateDataView }




    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.