IDalConnectionDescriptor2.ConnectAsPrivilege

Fore Syntax

ConnectAsPrivilege: DalConnectAsPrivilegeType;

Fore.NET Syntax

ConnectAsPrivilege: Prognoz.Platform.Interop.Dal.DalConnectAsPrivilegeType;

Description

The ConnectAsPrivilege property determines a database server connection with the specified privilege.

Comments

Connection with the privilege can be set only for Oracle servers Oracle 9.x\10.x\11.x.

Connection with the privileges may be required only for executing Foresight Analytics Platform operations that require assigning the parameters of the account that has the administration permissions in the Oracle. For example, when the SYSTEM user was locked by the safety requirements, and there is only one SYS user.

Fore Example

To execute the example, connect the Metabase and Dal system assemblies to the module. It is supposed that the repository is located at the Oracle server (Oracle DBMS 9.x\10.x\11.x), the server contains the SYS user with the Password password, and the repository contains a table with the Table identifier.

Sub UserProc;
Var
    MB: IMetabase;
    Driv: IDalDriver;
    Connect: IDalConnection;
    Connect2: IDalConnectionDescriptor2;
    Command: IDalCommand;
    ConnectDesc: IDalConnectionDescriptor;
    ConnectDescParams: IDalConnectionDescriptorParams;
Begin
    MB := MetabaseClass.Active;
    Driv := New DalOrcl8Driver.Create;
    ConnectDesc := Driv.CreateDescriptor;
    ConnectDescParams := ConnectDesc.Params;
    ConnectDescParams.Find("User Name").Value := "SYS";
    ConnectDescParams.Find("Password").Value := "Password";
    ConnectDescParams.Find("Host BSTR").Value := "test";
    ConnectDescParams.Find("Schema").Value := "PPRepository";
    //User with the SYS privilege
    Connect2 := ConnectDesc As IDalConnectionDescriptor2;
    Connect2.ConnectAsPrivilege := DalConnectAsPrivilegeType.SYSOPER;
    Connect := ConnectDesc.CreateConnection;
    Command := Connect.CreateCommand;
    Command.SQL := "select * from Table";
    Connect.StartTransaction;
    Command.Execute;
    Connect.Commit;
    Command.Close;
    Connect.Close;
End Sub UserProc;

After executing the example the SQL query is executed, the user account credentials with the SYSOPER privilege are specified for connection.

Fore.NET Example

To execute the example, add a link to the Dal system assembly. It is supposed that the repository is located at the Oracle server (Oracle DBMS 9.x\10.x\11.x), the server contains the SYS user with the Password password, and the repository contains a table with the Table identifier.

The specified procedure is an entry point for the .NET assembly.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dal;

Public Shared Sub Main(Params : StartParams);
Var
    MB: IMetabase;
    Driv: IDalDriver;
    Connect: IDalConnection;
    Connect2: IDalConnectionDescriptor2;
    Command: IDalCommand;
    ConnectDesc: IDalConnectionDescriptor;
    ConnectDescParams: IDalConnectionDescriptorParams;
Begin
    MB := Params.Metabase;
    Driv := New DalOrcl8Driver.Create();
    ConnectDesc := Driv.CreateDescriptor();
    ConnectDescParams := ConnectDesc.Params;
    ConnectDescParams.Find("User Name").Value := "SYS";
    ConnectDescParams.Find("Password").Value := "test";
    ConnectDescParams.Find("Host BSTR").Value := "test";
    ConnectDescParams.Find("Schema").Value := "PPRepository";
    //User with the SYS privilege
    Connect2 := ConnectDesc As IDalConnectionDescriptor2;
    Connect2.ConnectAsPrivilege := DalConnectAsPrivilegeType.dcaptSYSOPER;
    Connect := ConnectDesc.CreateConnection();
    Command := Connect.CreateCommand();
    Command.SQL := "select * from Table";
    Connect.StartTransaction();
    Command.Execute();
    Connect.Commit();
    Command.Close();
    Connect.Close();
End Sub;

After executing the example the SQL query is executed, the user account credentials with the SYSOPER privilege are specified for connection.

See also:

IDalConnectionDescriptor2