|
AnyDAC
|
The collection of macro substitution variables.
The Macros property is the collection of macro substitution variables. It is populated automatically after assigning CommandText, if ResourceOptions.MacroCreate = True. Otherwise it may be populated by hands. At Prepare call, macro values will be substituted into CommandText, if ResourceOptions.MacroExpand = True.
property Macros: TADMacros;
Executing Command, Preprocessing Command Text, CommandText, Params, Prepare, TADMacros, TADResourceOptions.MacroCreate, TADResourceOptions.MacroExpand
Substitute table name:
ADCommand1.CommandText.Text := 'select * from &Tab';
ADCommand1.Macros[0].AsIdentifier := 'Order Details';
ADCommand1.Prepare;
ShowMessage(ADCommand1.SQLText); // select * from "Order Details"Substitute WHERE condition:
ADCommand1.CommandText.Text := 'select * from MyTab {if !cond} where !cond {fi}';
ADCommand1.Macros[0].AsString := 'ID > 100';
ADCommand1.Prepare;
ShowMessage(ADCommand1.SQLText); // select * from MyTab where ID > 100
ADCommand1.Macros[0].Clear;
ADCommand1.Prepare;
ShowMessage(ADCommand1.SQLText); // select * from MyTabSee AnyDAC\Samples\Comp Layer\TADQuery\Macros demo for details.
|
What do you think about this topic? Send feedback!
|