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

Can I set a complete where condition in RAP - D6 RB10.04

edited September 2006 in RAP
Hi

I have been looking at lSQLBuilder.SearchCriteria and would like to know if
I can set the where clause in one go

I want to

SQLWhere := 'booking_no in (50025,50034) and booking_type = 'Q''

Is this possible or do I have to use the incremental construction in RAP.

The reason for this is that I want to front end my reports in an application
with a smart criteria screen and would like to generate the where condition
in the application and send it to the report as a parameter for RAP to use.

regards
Andrew

Comments

  • edited September 2006

    You need to do it in steps.

    SQLBuilder basically works like the QueryDesigner - they are organized like
    the tabs of the query designer interface. They both manipulate an underlying
    TdaSQL object that contains an object based description of a SQL statement
    (SelectTables[], SelectFields[], etc.).


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2006

    I recommend using RB's AutoSearch feature to implement "ask at runtime"
    search criteria. RB will automatically generate the dialog and modify the
    SQL Where clause for you.



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2006
    Nard

    Thanks for the quick reply.

    I have looked at Autosearch and the dialog is not suitable.

    So are you saying there is no way you can just substitute a whole where
    clause in?

  • edited September 2006

    - like most all of the dialogs in ReportBuilder, the AutoSearch dialog can
    be replaced. For an example of a custom autosearch dialog, check out
    RBuilder\Demos\AutoSearch\Custom AutoSearch Dialog.

    - No, you cannot just replace the where clause as a text string. That was
    the whole point of my prior response. The TdaSQLBuilder.SearchCriteria
    property can be used to access and modify a list of TdaCriteria items. Each
    TdaCriteria item describes a single search condition.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2006
    Sorry to butt in, but I have come accross a similar problem. What I did is
    replaced the entire SQL with a string list.

    In the query designer you go to the SQL Tab, right clack and choose edit
    SQL. You will get a warning about not being able to useg raphical tools
    anymore. Then Type in the select clause of the SQL (To generate the
    fields).

    Then in the OnDataPipelineOpen do something simlar to what you see below (I
    used the Customers Database that comes with the RB Demos):

    var
    LSQLBuilder : TdaSQLBuilder;
    LSQL : TStringList;
    begin
    // Must create a String List Cannot add lines directly as it tries to
    parse the SQL each time
    //and will error out if it is not complete
    LSQL := TStringList.Create;
    LSQL.Clear;
    LSQL.Add('SELECT customer.CustNo, customer.Company, ');
    LSQL.Add('customer.Addr1, customer.Addr2, ');
    LSQL.Add('customer.City, customer.State, ');
    LSQL.Add('customer.Zip, customer.Country, ');
    LSQL.Add('customer.Phone, customer.FAX, ');
    LSQL.Add('customer.TaxRate, customer.Contact, ');
    LSQL.Add('customer.LastInvoiceDate ');
    LSQL.Add('FROM "customer.db" customer ');

    LSQLBuilder := TdaSQLBuilder.Create(plCustomer);
    LSQLBuilder.SQL.SQLText := LSQL;
    LSQLBuilder.Free;

    LSQL.Free;
    end;

    As for your custom form I handled that by using a pass through functiuon
    (there is an exellent tutorial about making Delphi Forms appear in your
    EndUser App in the the Developers Guide (Displaying Delphi Forms From RAP,
    starting on page 387). If you work through the tutorial (about 2 horurs to
    do it properly) you will get the picture pretty quick.

    If you want I can send you an Example Delphi Project (which is an extension
    of one of the demo Projects I experimernted with to figure all this out). I
    am using D7, RB10.04.

    Nigel.

This discussion has been closed.