IDalCommand.CurrentParamsRow

Syntax

CurrentParamsRow: Integer;

Description

The CurrentParamsRow property returns the index of the current set of parameters.

Comments

Parameter values are specified in the Params collection. To move to the next set of parameters, use the NextParamsRow method. When the Execute method is executed, all the sets of parameters in the range from zero to CurrentParamsRow inclusive are processed. When the ExecuteWithoutLast method is executed, all the ranges in the range from zero to CurrentParamsRow excluding the values specified in the CurrentParamsRow set, are processed.

After executing the Execute or ExecuteWithoutLast method, the CurrentParamsRow property is set to zero. This enables the user to set values of the parameter sets again and execute the command.

Example

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;
    CommandEx : IDalCommandEx;
    Params : IDalCommandParams;
    sql : String;
    paramArraySize, i, j : Integer;
Begin
    MB := MetabaseClass.Active;
    DB_ORCL8 := MB.ItemById("DB").Open(NullAs 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 := 4;
    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
        For i := 0 To Command.CurrentParamsRow Do
            CommandEx := Command As IDalCommandEx;
            CommandEx.SetCurrentParamsRow(i);
            Debug.Write(Params.Item(0).Value);
            Debug.Write(" ");
            Debug.WriteLine(Params.Item(1).Value);
        End For;
        Command.ExecuteWithoutLast;
    End If;
End Sub UserProc;

After executing the example ten records are inserted into the table. The sets of parameters that exceeded the maximal set of processed strings are displayed in the console window.

See also:

IDalCommand