ExecuteWithoutLast: Integer;
The ExecuteWithoutLast method executes the command with all sets of parameters except for 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, which index is returned by the CurrentParamsRow property, is ignored on executing the method. This method is necessary when there is a chance that the maximum number of processed sets of parameters is exceeded.
Executing the example requires that the repository contains a database with the DB identifier and a table with the MyTable identifier.
Add links to the Dal, Db, and Metabase system assemblies.
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;
After executing the example ten records are inserted into the table.
See also: