Icon Querying Configuration Objects

Configuration objects are objects that are stored in the ElevateDB configuration file, which is represented by the special system-created Configuration database. Querying configuration objects can be accomplished by using the TEDBQuery component to execute queries against the Configuration database. This allows you to determine which configuration objects exist in the configuration along with specific information about the configuration objects.

The following example shows how to use a TEDBQuery component containing a SELECT statement to query the Databases Table in the Configuration database in order to see if the "Sales" database exists:

// This example uses a query component that
// has already been created and opened
// called MyQuery

with MyQuery do
   begin
   DatabaseName:='Configuration';
   SQL:='SELECT * FROM Databases '+
        'WHERE Name='+Engine.QuotedSQLStr('Sales');
   Open;
   if (RecordCount=1) then
      ShowMessage('The Sales database exists')
   else
      ShowMessage('The Sales database does not exist');
   end;

You can also use the TEDBSession Execute method as a quicker method to determine if a configuration object or objects exist. The Execute method returns the number of rows affected or returned by a particular SQL statement, so you can use the return value of an indication of whether any rows exist for the SELECT statement on the Configuration database:

// This example uses a session component that
// has already been created and opened
// called MySession

with MySession do
   begin
   if (Execute('SELECT * FROM Databases '+
               'WHERE Name='+Engine.QuotedSQLStr('Sales'))=1) then
      ShowMessage('The Sales database exists')
   else
      ShowMessage('The Sales database does not exist');      
   end;
Image