CreateCommandO(Option: DalCommandOption): IDalCommand;
Option. SQL query work mode.
The CreateCommandO method creates a command used for executing SQL queries in the specified mode.
Executing the example requires a server based on Microsoft SQL Server DBMS. The TestRepository repository is created on the server.
Add links to the Dal system assembly.
Sub UserProc;
Var
MSSQLDriver: IDalDriver;
MSSQLDescriptor: IDalConnectionDescriptor;
MSSQLParams: IDalConnectionDescriptorParams;
MSSQLConnect: IDalConnection;
Com: IDalCommand;
Cur: IDalCursor;
CurFields: IDalCursorFields;
i: Integer;
Begin
// Create a connection
MSSQLDriver := New DalMsSql2012Driver.Create;
MSSQLDescriptor := MSSQLDriver.CreateDescriptor;
MSSQLParams := MSSQLDescriptor.Params;
MSSQLParams.Find("User Name").Value := "user";
MSSQLParams.Find("Password").Value := "password";
MSSQLParams.Find("Host BSTR").Value := "mssql_server";
MSSQLParams.Find("Database").Value := "TestRepository";
MSSQLConnect := MSSQLDescriptor.CreateConnection;
// Create a command
Com := MSSQLConnect.CreateCommandO(DalCommandOption.NoCursorInQuery);
Com.SQL := "Select * From Table";
// Get command execution results
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 UserProc;
After executing the example a new DBMS server connection is created. A command will be created that executes SQL queries without cursor use. An SQL query will be executed and its results will be obtained. Results will be displayed in the development environment console.
See also: