IDalCommandParam.Size

Syntax

Size: Integer;

Description

The Size property determines maximum length of the value that parameter can take.

Comments

This property is relevant for parameters that have the String data type, and for repeated execution of the command with different values of the parameters.

On executing the command, if there is a value of the parameter that is greater than the previous one, the parameter with the length that corresponds to the current value of the parameter is recreated. It is necessary to set the Size property to speed up execution of the command excluding the situations of parameters recreation.

Example

Executing the example requires that the repository contains a database with the BD identifier. This database contains a table named Table_1 that contains the Field1 and Field2 fields.

Add links to the Dal, Db, and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Com: IDalCommand;
    Params: IDalCommandParams;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("BD").Open(NullAs 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 := 20;
    Com.MaxParamsRows := 4;
    //First value
    Params.Item(0).Value := 1;
    Params.Item(1).Value := "First";
    Com.NextParamsRow;
    //Second value
    Params.Item(0).Value := 2;
    Params.Item(1).Value := "Second";
    Com.NextParamsRow;
    //Third value
    Params.Item(0).Value := 3;
    Params.Item(1).Value := "Third";
    Com.NextParamsRow;
    //Forth value
    Params.Item(0).Value := 4;
    Params.Item(1).Value := "Fourth";
    Com.Execute;
    Com.Close;
End Sub UserProc;

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:

IDalCommandParam