FireDAC.Stan.Param.TFDParam.ArrayType
Delphi
property ArrayType: TFDParamArrayType read FArrayType write SetArrayType default atScalar;
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | published | FireDAC.Stan.Param.pas | FireDAC.Stan.Param | TFDParam |
Description
Represents the type of an array-valued TFDParam object.
The ArrayType property represents the type of an array-valued TFDParam object, which can be:
atScalar
- a non array-valued parameter.atArray
- an array-valued parameter, where the parameter is array-valued and unified with other parameters. Mostly it is an Array DML command parameter.atTable
- an array-valued parameter, where the parameter has a DBMS-specific array data type.
Example
Here is a code snippet that shows how to use TFDParam.ArrayType=atTable
to send arrays to server:
Delphi:
FDQuery1.SQL.Text := 'insert into FDQA_Array values (:id, :name, :items)';
FDQuery1.Params[0].AsInteger := 1;
FDQuery1.Params[1].AsString := 'test1';
// Setup array typed parameter
FDQuery1.Params[2].ArrayType := atTable;
FDQuery1.Params[2].ArraySize := 4;
// InterBase and Firebird require to specify full field name as parameter data type name
if (FDConnection1.RDBMSKind = TFDRDBMSKinds.Interbase) or (FDConnection1.RDBMSKind = TFDRDBMSKinds.Firebird) then
FDQuery1.Params[2].DataTypeName := 'FDQA_ARRAY.ITEMS';
// Assign array type parameter values
FDQuery1.Params[2].AsStrings[0] := 'item1';
FDQuery1.Params[2].AsStrings[1] := 'item2';
FDQuery1.Params[2].AsStrings[2] := 'item3';
FDQuery1.Params[2].AsStrings[3] := 'item4';
// Execute SQL command
FDQuery1.ExecSQL;
C++:
FDQuery1->SQL->Text="Insert into FDQA_Array values (:id, :name, :items)";
FDQuery1->Params->Items[0]->AsInteger=1;
FDQuery1->Params->Items[1]->AsString="test1";
// Setup array typed parameter
FDQuery1->Params->Items[2]->ArrayType=atTable;
FDQuery1->Params->Items[2]->ArraySize=4;
// InterBase and Firebird require to specify full field name as parameter data type name
if (FDConnection1->RDBMSKind==TFDRDBMSKinds::Interbase || FDConnection1->RDBMSKind==TFDRDBMSKinds::Firebird)
FDQuery1->Params->Items[2]->DataTypeName="FDQA_ARRAY.ITEMS";
// Assign array type parameter values
FDQuery1->Params->Items[2]->AsStrings[0]="item1";
FDQuery1->Params->Items[2]->AsStrings[1]="item2";
FDQuery1->Params->Items[2]->AsStrings[2]="item3";
FDQuery1->Params->Items[2]->AsStrings[3]="item4";
// Execute SQL command
FDQuery1->ExecSQL();
- Note: This code snippet works for InterBase, Firebird and PostgreSQL.
See Also
- FireDAC InterBase Arrays sample
- FireDAC PostgreSQL Arrays sample