Direction: DalParamDirection;
The Direction property determines a destination of SQL query parameter.
The property is set to DalParamDirection.Input by default.
Executing the example requires that the repository contains a database with the BD identifier. The server, on which the database was configured, contains the Func_1 function that calculates any value.
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;
After executing the example a command that executes the function or procedures stored at the server is created. One parameter, in which the result of function execution returns, is created for the command. After executing the example the "v" variable contains the Func_1 function execution result.
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;
After executing the example the connection to the TestShema scheme placed at the Test server is established. Connection is established using the Oracle 9.x\10.x\11.x driver. The procedure that returns cursor that contains all records of the Table_1 table is executed within this scheme. A 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: