Home RAP

Changing SQL statements

edited February 2003 in RAP
Hallo,

I have some troubles. I change the SQL statement with following code:

if GetSQLObject(aReport,aSQL) then begin
aSQL.EditSQLAsText:= true;
aSQL.MagicSQLText.Clear;
aSQL.MagicSQLText.add(sSQL);
end;
This method will be called on BeforePrint. The sSQL has the same SQL
statement like to design time, only some macros defined by me will be
replaced.

The troubles that I get are, if I have a Report, where I also have where
statement with search dialog. I get in this case exception.

I would like to know why I get the exception and how to resolve it?

Thanks,
Stasa

Comments

  • edited February 2003

    1. RB's built-in AutoSearch feature and EditSQLAsText are NOT compatible.
    See the article below for more details about this. If you try this in the
    Data workspace, you will see that once you edit the SQL text, the options to
    maintain the query go away.

    2. One alternative might be to create your own custom dataview class and add
    the logic there. For example, if you are using ADO, rather using
    TdaADOQueryDataView, create a TmyADODataView class and register it for use
    with RB. See RBuilder\Source\daADO.pas as an example.


    3. What you are trying to accomplish? Can you provide more details?



    ---------------------------------------------
    Tech Tip: Limitations of using TdaSQL.SQLText
    ----------------------------------------------

    The TdaSQL object can contain either an object based description of the SQL
    (SelectTables[], SelectFields[], etc.) that it uses to generate SQLText OR
    it contain a SQLText string. If you specify the SQLText string then TdaSQL
    will not generate any SQLText. Therefore the built-in AutoSearch and Linking
    features can no longer be used - because these require that special SQLText
    be generated.

    If you want to use AutoSearch with a SQLText, you will need to handle this
    in your custom dataview code. For an example see RBuilder\Demos\AutoSearch
    and see the TdaQueryDataView.CreateAutoSearchFields and
    TdaQueryDataView.ReportGetAutoSearchValuesEvent methods in
    daQueryDataView.pas.



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

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