FireDAC.Comp.Client.TFDUpdateSQL.InsertSQL
Delphi
property InsertSQL: TStrings index 0 read GetSQL write SetSQL;
C++
__property System::Classes::TStrings* InsertSQL = {read=GetSQL, write=SetSQL, index=0};
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | published | FireDAC.Comp.Client.pas FireDAC.Comp.Client.hpp |
FireDAC.Comp.Client | TFDUpdateSQL |
Description
Specifies an SQL statement to use when applying the insertion of a record.
Set InsertSQL to an SQL statement to use when applying a record insertion to a database.
To submit a new field value to a command, use the :NEW_<field name>
or :<field name>
parameter name. Statements can use additional parameters and macros. To get access to the parameters or macros collection, use the Commands property.
If the statement fetches new record field values (identified or modified in the trigger) using parameters, then use the :NEW_<field name>
or :<field name>
parameter name to include parameter values in the record, and set the parameter types to ptOutput
. If the statement will produce a record set, then its fields must have the same names as in dataset.
To create an INSERT
statement at design time, use the UpdateSQL editor. For that, double-click the TFDUpdateSQL component. Also, you can use stored procedure calls or other SQL commands to apply insertion.
See the Commands property for details on how to use macros or additional parameters in the command text.
Example
// SQL Server sample
FDUpdateSQL1.InsertSQL := 'INSERT INTO [Shippers] (COMPANYNAME, PHONE) ' +
'VALUES (:NEW_COMPANYNAME, :NEW_PHONE); SELECT SCOPE_IDENTITY() AS SHIPPERID';
// Oracle sample
FDUpdateSQL1.InsertSQL := 'INSERT INTO ADDEMO."Shippers" (COMPANYNAME, PHONE) ' +
'VALUES (:NEW_COMPANYNAME, :NEW_PHONE) RETURNING SHIPPERID INTO :NEW_SHIPPERID';
FDUpdateSQL1.Commands[arInsert].ParamByName('NEW_SHIPPERID').ParamType := ptOutput;