MaxParamsRows: Integer;
The MaxParamsRows property determines the maximum number of processed sets of parameter values.
This property determines the maximum number of sets that can be specified and processed on calling the Execute method. Parameter values are set in the Params collection. To move to the next set, call the NextParamsRow method.
NOTE. Before the MaxParamsRows property value is specified, specify the data type for each parameter.
Initially, the cursor is put on the first set of parameters, that is why the number of transitions using the NextParamsRow method must be one transition less than the number of populated sets.
Executing the example requires that the repository contains a database with the DB identifier. The DBMS, to which the database is set up, contains the T_Table table. The table has two fields: string and real.
Sub UserProc;
Var
Mb: IMetabase;
DB: IDatabaseInstance;
Command: IDalCommand;
Params: IDalCommandParams;
Sql: String;
ParamRows, i: Integer;
Begin
MB := MetabaseClass.Active;
DB := MB.ItemById("DB").Open(Null) As IDatabaseInstance;
Sql := "Insert Into T_Table (Field, Field1) Values(:1,:2)";
Command := DB.Connection.CreateCommand(Sql);
Command.Type := DalCommandType.Text;
Command.Parse;
Command.Prepare;
Params := Command.Params;
//Specify types of parameters
Params.Item(0).DataType := DbDataType.String;
Params.Item(1).DataType := DbDataType.Float;
//Number of sets of parameters
ParamRows := 5;
Command.MaxParamsRows := ParamRows;
i := 1;
While i <= ParamRows Do
Params.Item(0).Value := "№ " + i.ToString;
Params.Item(1).Value := Math.RandBetween(0, i);
If i <> ParamRows Then
Command.NextParamsRow;
End If;
i := i + 1;
End While;
Command.Execute;
End Sub UserProc;
On executing the example five records are inserted into the table. Five parameters sets are formed before inserting.
See also: