Show/Hide Toolbars

TMS Aurelius Documentation

All TDatabaseManager methods that perform some operation in the database schema generate an SQL script, available in the SQLStatements property. Most methods also execute such statements (like BuildDatabase, UpdateDatabase and DropDatabase). Some methods do not execute, like ValidateDatabase. But in all cases, the associated SQL script is available.

 

In TDatabaseManager you have the option to disable execution of SQL statements. This way you have the freedom to execute the statements as you want, using you our error handling system, your own graphical user interface to execute them, etc. To do that, just set SQLExecutionEnabled property to false. Examples:

 

uses

  Aurelius.Engine.DatabaseManager;

{...}

var

  DBManager: TDatabaseManager;

 

  procedure OutputSQLScript;

  var

    SQLStatement: string;

  begin

    for SQLStatement in DBManager.SQLStatements do

      WriteLn(SQLStatement);

  end;

 

begin

  DBManager := TDatabaseManager.Create(MyConnection);

  DBManager.SQLExecutionEnabled := false;

 

  // Output an SQL Script to build a new database

  DBManager.BuildDatabase;

  OutputSQLScript; 

 

  // Output an SQL to drop the full database

  DBManager.DropDatabase;

  OutputSQLScript;

 

  // Output an SQL script to update the existing database

  DBManager.UpdateDatabase;

  OutputSQLScript;  

 

  DBManager.Free;

end;

 

Note that when SQLExecutionEnabled property is false, calling UpdateDatabase is equivalent to calling ValidateDatabase, so this code:

 

  // Output an SQL script to update the existing database

  DBManager.SQLExecutionEnabled := false;

  DBManager.UpdateDatabase;

  OutputSQLScript;

 

Could also be written just as:

 

  // Output an SQL script to update the existing database

  // Regardless of value of SQLExecutionEnabled property

  DBManager.ValidateDatabase;

  OutputSQLScript;