Working with Macros
Macros help you to change
SQL statements dynamically. They allow partial replacement of the
query statement by user-defined text. Macros are identified by their names which are then referred from
SQL statement to replace their occurrences for associated values.
First step is to assign macros with their names and values to a dataset object.
Then modify
SQL statement to include macro names into desired insertion points. Prefix each name with & ("at") sign to let UniDAC discriminate them at parse time. Resolved
SQL statement will hold macro values instead of their names but at the right places of their occurrences. For example, having the following statement with the TableName macro name:
SELECT * FROM &TableName
You may later assign any actual table name to the macro value property leaving your
SQL statement intact.
Query1.SQL.Text := 'SELECT * FROM &TableName';
Query1.MacroByName('TableName').Value := 'Dept';
Query1.Open;
UniDAC replaces all macro names with their values and sends
SQL statement to the server when
SQL execution is requested.