ExecuteWithoutLast: Integer;
The ExecuteWithoutLast method executes the command with all sets of parameters except the last one and returns the number of processed records.
This method executes the same functions as the Execute method, but the last set of parameter values, the index of which returns the CurrentParamsRow property is ignored on executing this method. This method is necessary when the excess of the maximal number of the processed sets of parameters is possible.
Executing the example requires a database with the DB identifier and a table with the MyTable identifier in the repository.
Sub UserProc;
Var
Mb : IMetabase;
DB_ORCL8 : IDatabaseInstance;
Command : IDalCommand;
Params : IDalCommandParams;
sql : String;
paramArraySize, i, j : Integer;
Begin
MB := MetabaseClass.Active;
DB_ORCL8 := MB.ItemById("DB").Open(Null) As IDatabaseInstance;
sql := "insert into MyTable (field,field1) values(:1,:2)";
Command := DB_ORCL8.Connection.CreateCommand(sql);
Command.Type := DalCommandType.Text;
Command.Parse;
Command.Prepare;
Params := Command.Params;
Params.Item(0).DataType := DbDataType.String;
Params.Item(1).DataType := DbDataType.Float;
paramArraySize := 3;
Command.MaxParamsRows := paramArraySize;
j := 1;
For i := 1 To 10 Do
Params.Item(0).Value := "№ "+i.ToString;
Params.Item(1).Value := i + 0.1;
If (j < paramArraySize) Then
Command.NextParamsRow;
j := j+1;
Else
Command.Execute;
j:= 1;
End If;
End For;
If j > 1 Then
Command.ExecuteWithoutLast;
End If;
End Sub UserProc;
10 records are inserted into the table after executing this example.
See also: