DataType: DbDataType;
The DataType property determines a data type of SQL query parameter.
Executing the example requires that the repository contains a database with the BD identifier. A table with the Table_1 physical name that contains the Field1 and Field2 fields is created in this database.
Sub Main;
Var
MB: IMetabase;
DB: IDatabaseInstance;
Com: IDalCommand;
Params: IDalCommandParams;
Begin
MB := MetabaseClass.Active;
DB := MB.ItemById("BD").Open(Null) As IDatabaseInstance;
Com := DB.Connection.CreateCommand("Insert Into Table_1 (Field1,Field2) Values(:1,:2)");
Com.Parse;
Params := Com.Params;
Params.Item(0).DataType := DbDataType.Integer;
Params.Item(1).DataType := DbDataType.String;
Params.Item(1).Size := 50;
Com.MaxParamsRows := 4;
//The first value
Params.Item(0).Value := 1;
Params.Item(1).Value := "The first";
Com.NextParamsRow;
//The second value
Params.Item(0).Value := 2;
Params.Item(1).Value := "The second";
Com.NextParamsRow;
//The third value
Params.Item(0).Value := 3;
Params.Item(1).Value := "The third";
Com.NextParamsRow;
//The fourth value
Params.Item(0).Value := 4;
Params.Item(1).Value := "The fourth";
Com.Execute;
Com.Close;
End Sub Main;
After executing the example the connection to the BD database is established, the SQL query that inserts the records to the Table_1 table is executed. The fields values are represented as the collection of parameters values of the command that is executed at the database server.
See also: