IDalCommandParam.Direction

Syntax

Direction: DalParamDirection;

Description

The Direction property determines a destination of the SQL query parameter.

Comments

The DalParamDirection.Input value is set to the property by default.

Example 1

Executing the example requires a database with the BD identifier in the repository. There is the Func_1 function that calculates any value on the server on which the database was set.

Sub Main;

Var

MB: IMetabase;

DB: IDatabaseInstance;

Com: IDalCommand;

v: Variant;

Begin

MB := MetabaseClass.Active;

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

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

Com.Type := DalCommandType.StoredProcedure;

Com.SQL := "Func_1";

Com.Params.Add("Param").Direction := DalParamDirection.ReturnValue;

Com.Execute;

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

Com.Close;

End Sub Main;

A command that executes the function or procedures stored on the server is created after executing this example. One parameter, in which the result of function execution returns, is created for the command. The result of the Func_1 function execution is contained in the "v" variable after executing this example.

Example 2

Sub Main;

Var

Driv: IDalDriver;

Connect: IDalConnection;

Command: IDalCommand;

ConnectDesc: IDalConnectionDescriptor;

ConnectDescParams: IDalConnectionDescriptorParams;

Cur: IDalCursor;

f: IDalCursorField;

Begin

Driv := New DalOrcl8Driver.Create;

ConnectDesc := Driv.CreateDescriptor;

ConnectDescParams := ConnectDesc.Params;

ConnectDescParams.Find("User Name").Value := "TestUser";

ConnectDescParams.Find("Password").Value := "TestUser";

ConnectDescParams.Find("Host BSTR").Value := "Test";

ConnectDescParams.Find("Schema").Value := "TestShema";

Connect := ConnectDesc.CreateConnection;

Command := Connect.CreateCommand;

Command.SQL := "Begin" + #13 + #10 +

"OPEN :Cursor1 For Select * From Table_1;" + #13 + #10 +

"End;";

Command.Parse;

Command.Params.Item(0).Direction := DalParamDirection.RefCursor;

Command.Execute;

Cur := Command.Params.Item(0).Value As IDalCursor;

While Not Cur.Eof Do

For Each f In Cur.Fields Do

Debug.Write(f.Value + " ");

End For;

Debug.WriteLine("");

Cur.Next;

End While;

Cur.Close;

Command.Close;

Connect.Close;

End Sub Main;

The connection to the TestShema scheme placed on the Test server is established after executing this example. Connection is established using the Oracle 9.x\10.x\11.x driver. Procedure that returns cursor that contains all records of the Table_1 table is executed within this scheme. Cursor is obtained through the first parameter of the command. Values of all fields by all records are displayed in the development environment console.

See also:

IDalCommandParam