Oracle Connection Attributes

The SET CONNECTION_ATTRIBUTES command allows you to declare a connection to one Oracle database server and to supply authentication attributes necessary to connect to the server.

You can declare connections to more than one Oracle database server by issuing multiple SET CONNECTION_ATTRIBUTES commands. The actual connection takes place when the first request referencing that connection is issued. You can issue SET CONNECTION_ATTRIBUTES commands in a FOCEXEC, at the FOCUS command prompt or in a FOCUS-supported profile. The profile can be encrypted.

In this section:

Connecting to an Oracle Database Server

Authenticating a User on an Oracle Database Server

Selecting an Oracle Connection to Access

Oracle Support for DATABASE LINKs

How to:

Declare Connection Attributes for Oracle

Query the Declared Oracle Connections

Select an Oracle Connection to Access

Example:

Declaring Connection Attributes for Oracle

Selecting an Oracle Connection to Access

If you issue multiple SET CONNECTION_ATTRIBUTES commands:


Top of page

Connecting to an Oracle Database Server

The data adapter supports connections to:

Once you are connected to an Oracle database server, that server may define Oracle DATABASE LINKs that can be used to access Oracle tables on other Oracle database servers.


Top of page

Authenticating a User on an Oracle Database Server

Users can issue multiple SET CONNECTION_ATTRIBUTES commands to supply valid user IDs and passwords.

If needed, the DBA or some other authorized person at your site will supply you with a valid Oracle user ID and password.

It may be desirable to prompt users for their Oracle password instead of coding it in a procedure. In this case, use a Dialogue Manager variable in its place, and retrieve the value using -CRTFORM or -PROMPT facilities. If you use -CRTFORM, you can make the password field non-displayable for additional security.

A valid Oracle user ID and password must be supplied before issuing commands that access the Oracle RDBMS. If a valid Oracle login ID and password have not been supplied, an error message is returned. You should respond by correcting and re-issuing the SET CONNECTION_ATTRIBUTES command.

The SET CONNECTION_ATTRIBUTES command stores both the Oracle login ID and password in user virtual storage; it does not immediately initiate a login to Oracle. The actual login is deferred until a subsequent command is issued that requires the services of the Oracle RDBMS.


Top of page

Syntax: How to Declare Connection Attributes for Oracle

SQL [SQLORA] SET CONNECTION_ATTRIBUTES [connection_name]/userid,password

where:

SQLORA
Indicates the Oracle Data Adapter. You can omit this value if you previously issued the SET SQLENGINE command.

connection_name
Specifies a remote instance using an Oracle TNSNAME (the net service name used as a connect descriptor to an Oracle database server across the network). If omitted, the local database server will be set as the default.

userid
Is the primary authorization ID by which you are known to Oracle, up to 30 characters in length.

password
Is the password associated with the user ID, up to 30 characters in length.

Note: SET USER is a synonym for SET CONNECTION_ATTRIBUTES, supported for compatibility with earlier releases of the data adapter. However, note that the symbol used for separating the connection attribute from the authentication information and the symbol used for separating the user ID from the password have changed in FOCUS 7.2.


Top of page

Syntax: How to Query the Declared Oracle Connections

Issue the following query command to list status information for all declared connections:

SQL SQLORA ? SERVERS

Top of page

Example: Declaring Connection Attributes for Oracle

Refer to the following diagram in conjunction with these examples:

The following SET CONNECTION_ATTRIBUTES command connects to the Oracle database server named TNSNAMEA with an explicit user ID and password:

SQL SQLORA SET CONNECTION_ATTRIBUTES TNSNAMEA/USERA,PWDA

The following SET CONNECTION_ATTRIBUTES command connects to a local Oracle database server with an explicit user ID and password:

SQL SQLORA SET CONNECTION_ATTRIBUTES /USERA,PWDA

Top of page

Selecting an Oracle Connection to Access

Once all Oracle database servers to be accessed have been declared using the SET CONNECTION_ATTRIBUTES command, there are two ways to select a specific Oracle connection from the list of declared connections:


Top of page

Syntax: How to Select an Oracle Connection to Access

SQL [SQLORA] SET DEFAULT_CONNECTION [connection_name]

where:

SQLORA
Indicates the Oracle Data Adapter. You can omit this value if you previously issued the SET SQLENGINE command.

connection_name
Is the connection name specified in a previously issued SET CONNECTION_ATTRIBUTES command. If omitted, the local database server is set as the default. If this connection name has not been previously declared, a FOC1671 message is issued.

Note:


Top of page

Example: Selecting an Oracle Connection to Access

The following SET DEFAULT_CONNECTION command selects the Oracle database server named TNSNAMEB as the default Oracle database server:

SQL SQLORA SET DEFAULT_CONNECTION TNSNAMEB

Note: You must have previously issued a SET CONNECTION_ATTRIBUTES command for TNSNAMEB.


Top of page

Oracle Support for DATABASE LINKs

You can be connected to one Oracle database server and access a table on another Oracle database server (without actually connecting to the second server) if the first server has a DATABASE LINK defined for the table.

To access a remote Oracle table using DATABASE LINKs, the following conditions must exist:

Once you have met the above conditions, all requests for the table will be processed on the remote Oracle database server specified using the DATABASE LINK name. Using this method is another way to access multiple remote servers in one SQL request.


Information Builders