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

Parameters in SQL

edited August 2005 in General
Hi,

Using ReportExplorer, ReportDesigner & Report, how to assign parameters in
SQL Code ?

Example:

SELECT ID_DEPTO, NAME FROM DEPTOS WHERE ID_DEPTO=

How to change "" in user aplication ?

Thanks,

Samuel

Comments

  • edited August 2005
    Hi Samuel,

    Take a look at the AutoSearch feature in ReportBuilder. This allows you to
    change the Where clause on the fly in order to filter the report output
    after generation. There are numerous examples of using the Autosearch
    feature in the Report Explorer demo as well as in the
    \RBuilder\Demos\AutoSearch\... directory.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2005
    Hi,

    I need to change parameters in WHERE clause in aplication like
    \RBuilder\Demos\4. EndUser Databases\Oracle 8\3. DOA\enduser.dpr.

    Example (in Oracle):

    1) Compile & run \RBuilder\Demos\4. EndUser Databases\Oracle 8\3.
    DOA\enduser.dpr
    2) Create New Report
    3) On "Data", "Query Design", "SQL", right click and select "Edit SQL" and
    specity this query " SELECT * FROM ALL_TABLES WHERE OWNER='SYS' "
    4) Create report with fields OWNER and TABLE_NAME
    5) Save Report

    How to transform 'SYS' in parameter ? How to user specify ONWER NAME in the
    enduser.dpr without change application code ? (change only Report Template)

    The RAP can resolve this ?

    Thanks,

    Samuel


  • edited August 2005
    Hi Samuel,

    If you have RB 9.0x you can use the TdaSQLBuilder object to easily alter the
    SQL object in RAP. Take a look at the TdaSQLBuilder topic in the
    ReportBuilder help file for detailed information on how it is to be used and
    many code examples.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2005
    Sorry,

    I try but this not work (see sample).

    I specify the code bellow in ReportBeforeOpenDataPipelines,
    ReportOnInitializeParameters, OnCreate:

    var
    lSQLBuilder : TdaSQLBuilder;
    begin
    lSQLBuilder := TdaSQLBuilder.Create(Report.DataPipeline);
    lSQLBuilder.Clear;
    lSQLBuilder.SelectTables.Add('All_TABLES');
    lSQLBuilder.SelectFields.AddAllFields;
    lSQLBuilder.SearchCriteria.AddAutoSearch('ALL_TABLES', 'OWNER',
    'Like', 'WRO');
    { lSQLBuilder.ApplyUpdates;}
    lSQLBuilder.Free;
    end;

    What is happening ?

    Samuel

  • edited August 2005
    Hi Samuel,

    The code you have below should work provided "All_TABLES" is the name of a
    single table in your database, "OWNER" is a field in the ALL_TABLES table
    and you uncomment the "lSQLBuilder.ApplyUpdates" line.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2005
    Hi,

    When uncomment "ApplyUpdates" I receive this error in RAP (..."'(' or '['
    expected...." ).

    My Report Builder is 9.02 Enterprise Edition.

    Samuel


  • edited August 2005
    Hi Samuel,

    Sorry, you are correct, the ApplyUpdates is called automatically in RAP. In
    my testing with code almost identical to yours, I was able to get a
    successful output. This was using the DBDEMOS database included with
    Delphi. Below is my RAP code.

    procedure ReportBeforeOpenDatapipelines;
    var
    lSQLBuilder : TdaSQLBuilder;
    begin

    lSQLBuilder := TdaSQLBuilder.Create(Report.DataPipeline);
    lSQLBuilder.Clear;
    lSQLBuilder.SelectTables.Add('customer');
    lSQLBuilder.SelectFields.AddAllFields;
    lSQLBuilder.SearchCriteria.AddAutoSearch('customer', 'company', 'Like',
    'K');
    lSQLBuilder.Free;

    end;

    --
    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.