FireDAC.Comp.Script.TFDScript.SQLScripts
Delphi
property SQLScripts: TFDSQLScripts read FSQLScripts write SetSQLScripts;
C++
__property TFDSQLScripts* SQLScripts = {read=FSQLScripts, write=SetSQLScripts};
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | published | FireDAC.Comp.Script.pas FireDAC.Comp.Script.hpp |
FireDAC.Comp.Script | TFDScript |
Description
The collection of the SQL scripts.
Use the SQLScripts property to store and manage SQL scripts in the application memory, instead of in the external OS files.
Each collection item has the Name property, identifying a script, and the SQL property, actually containing a script. A script can be referenced by its name. The item with zero index is the main (root) script and the execution starts from it.
The loading mechanism of an SQL script can be overridden using the OnGetText event handler. Alternatively, an SQL script can be submitted from an external OS file using the SQLScriptFileName property. The SQLScriptFileName property has higher priority than the SQLScripts property.
Note that the ExecuteFile and ExecuteScript methods clear the existing SQLScripts content.
Example
with FDScript1.SQLScripts do begin Clear; with Add do begin Name := 'root'; SQL.Add('@first'); // explicitly call 'first' script SQL.Add('@second'); // explicitly call 'second' script end; with Add do begin Name := 'first'; SQL.Add('create table t1 (...);'); SQL.Add('create table t2 (...);'); end; with Add do begin Name := 'second'; SQL.Add('create procedure p1 (...);'); SQL.Add('create procedure p2 (...);'); end; end; FDScript1.ValidateAll; FDScript1.ExecuteAll;