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. The table with the Table_1 physical name that contains the Field1and Field2 fields is created on this database.

Sub Main;

Var

MB: IMetabase;

DB: IDatabaseInstance;

Com: IDalCommand;

Params: IDalCommandParams;

Begin

MB := MetabaseClass.Active;

DB := MB.ItemById("BD").Open(Null) As 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;

//The first value

Params.Item(0).Value := 1;

Params.Item(1).Value := "The first";

Com.NextParamsRow;

//The second value

Params.Item(0).Value := 2;

Params.Item(1).Value := "The second";

Com.NextParamsRow;

//The third value

Params.Item(0).Value := 3;

Params.Item(1).Value := "The third";

Com.NextParamsRow;

//The fourth value

Params.Item(0).Value := 4;

Params.Item(1).Value := "The fourth";

Com.Execute;

Com.Close;

End Sub Main;

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