Search Results for

    Show / Hide Table of Contents

    Components Overview

    Here is a brief summary of the installed components.

    TatVisualQuery Component

    TatVisualQuery is a component for visual SQL building. By dropping it on a form and setting some properties, your end-user will be able to build their own SQL statements with a friendly interface.

    TatVisualQuery interface is tree-view like, where the first top node contains the name of the query being built. Each node below this one is related to an SQL part:

    • Source tables: allows user to choose which tables records will come from, and how the tables will be linked.

    • Data fields: allows choosing of fields that will be included in Select clause of SQL.

    • Filter conditions: allows filtering of records (Where clause).

    • Grouping fields: specificies grouping for records (which fields will be used for grouping).

    • Ordering fields: specifieds fields for ordering records.

    • Parameter editors: provides a higher-level interface where programmer or end-users can define parameters to be linked to SQL (similar to %parameter syntax in Tquery component). This way end-user can just change parameters in order to change SQL.

    For more information about TatVisualQuery properties and methods, see the component reference at online help from IDE.

    Quick start

    In order to have TatVisualQuery component running, you should follow these steps:

    1. Drop a TatVisualQuery component on a form.

    2. Drop one TatDatabase components available in Query Studio palette. Choose the one which matches the db engine you want to use. Options are TatBDEDatabase, TatADODatabase, TatIBXDatabase or TatDBXDatabase.

    3. Set TatDatabase component properties accordingly. For example, if using TatBDEDatabase, set its DatabaseName property to the database name you want to connect to.

    4. Set TatVisualQuery.Databased property to point to the TatDatabase component you have just added.

    The fours steps above will make TatVisualQuery to work. You will be able to construct queries, but will be better if you could USE the built queries. The built SQL is available in MetaSQLDef property:

    BuiltMetaSQL := VisualQuery1.MetaSQLDef.MetaSQL.SQL;
    

    However, TatVisualQuery component can perform a higher level of interface and update automatically the dataset component you want to use:

    5. Drop the dataset component you want to use (for example, TQuery for BDE engine, or TADOQuery for ADO engine).

    6. Set TatVisualQuery.TargetDataset component to point to the dataset component.

    7. Set TatVisualQuery.AutoQueryOpen to True.

    That's all you need to get it running. TatVisualQuery will automatically update and reopen your TQuery as end-user changes its query definitions. If you attach a DBGrid to the dataset, you will see query results.

    TatCustomDatabase Class

    TatCustomDatabase is a special TatDatabase which does not connect to any database. Instead, it provides events for you to "simulate" a database connection and retrieve field and table names from those events. Whenever you want your enduser to build an SQL but not connected to a database, use TatCustomDatabase component to provide the available tables and fields for the end-user.

    Component events:

    TatRetrieveTableNameListEvent = procedure(const AList: TStrings) of object;
    property OnRetrieveTableNameListEvent: TatRetrieveTableNameListEvent;
    

    Use this event to provide the names of tables which can be selected from. Fill the AList parameter with the table names.

    Example:

    AList.Add('Customer');
    AList.Add('Orders');
    
    TatRetrieveFieldNameListEvent = procedure(const ATableName: string; const AList: TStrings) of object;
    property OnRetrieveFieldNameListEvent: TatRetrieveFieldNameListEvent;
    

    Use this event to provide the names and types of fields which can be selected in the table specified by ATableName parameter. Fill the AList parameter with the field names. The field type must be typecasted to a TObject and inserted in the Objects property of the list.

    Example:

    if UpperCase(ATableName) = 'CUSTOMER' then
    begin
      AList.AddObject('CustNo', TObject(Ord(ftInteger)));
      AList.AddObject('Company', TObject(Ord(ftString)));
      //And so on...
    end;
    

    Custom database connections

    Query Studio already provides several database connection components, descending from TatCustomDatabase. But since not every Delphi environments have the specific components installed, you must install the components manually, by following instructions here.

    TatMetaSQLDefs and TatMetaSQLDef classes

    TatMetaSQLDefs class holds a collection of TatMetaSQLDef classes, which in turn contains information of queries built in TatVisualQuery. TatVisualQuery holds this collection in MetaSQLDefs property, and it is built this way (as a collection) because it can hold more that just one query. Once the TatVisualQuery component holds more than one query, end-user can choose what query to edit/execute by right - clicking on left top icon of TatVisualQuery component and choosing the query from the popup menu that is displayed.

    For more information about TatMetaSQLDef properties and methods, see the component reference at online help from IDE.

    In This Article
    Back to top TMS Query Studio v1.16
    © 2002 - 2023 tmssoftware.com