IDalCommand.CreateCursor

Syntax

CreateCursor: IDalCursor;

Description

The CreateCursor method creates the cursor that is used to move through data obtained by executing SQL query to database.

Comments

On creating the cursor the Execute method is executed automatically.

Example

Sub Main;

Var

MB: IMetabase;

DB: IDatabaseInstance;

Com: IDalCommand;

Cur: IDalCursor;

CurFields: IDalCursorFields;

i: Integer;

Begin

MB := MetabaseClass.Active;

DB := MB.ItemById("BD").Open(Null) As IDatabaseInstance;

Com := DB.Connection.CreateCommand("");

Com.SQL := "Select * From Table_1 Where Num1 > :Item";

Com.Parse;

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

Cur := Com.CreateCursor;

While Not Cur.Eof Do

CurFields := Cur.Fields;

For i := 0 To CurFields.Count - 1 Do

Debug.Write(CurFields.Item(i).Value);

Debug.Write(" ");

End For;

Debug.WriteLine("");

Cur.Next;

End While;

Cur.Close;

Com.Close;

End Sub Main;

After executing the example the connection to the BD database is established and the SQL query that selects all records from the Table_1 table, for which the value of the Num1 field is greater than 1, is executed. Values of all fields, that the current record has, are displayed in the console window on each transition to the next record which satisfies the condition.

See also:

IDalCommand