Show TOC

sql_connectLocate this document in the navigation structure

Use

Use this command to create an SQL session with the database for the specified database user.

If you do not specify a user, the system uses the data of the DBM operator to create the session. Therefore, only those database statements for which the DBM operator is authorized, can be executed in this case.

When executing DBM commands that require an SQL session, in most cases the session is opened and closed implicitly. It is therefore unnecessary that you open an SQL session explicitly.

We only recommend using the DBM command for opening an SQL session if you are dealing with SQL statements that can only be executed by a particular database user, or for performance reasons, if you want to transfer a large number of SQL statements.

In this case, open the SQL session and specify the required database user, execute the SQL statements (see: sql_execute) and then close the SQL session (see: sql_release).

Prerequisites
  • You have the server permission DBInfoRead or AccessSQL.

  • You are working in the script or session mode.

Structure

sql_connect <user_identification>

<user_identification> :: = <user_spec> | <user_type>

<user_spec> :: = <database_user_name>,<database_user_password>

<user_type> :: = user-type=<value>

Option

Description

<database_user_name>

Name of the database user

<database_user_password>

Password of the database user

user-type=<value>

User type

Possible values are: DBM | DBA | SAP

DBM: DBM operator

DBA: database system administrator

SAP: database user of the SAP application

Result

OK

In the event of errors, see Reply Format.

Example

Log on to Database Manager CLI in session mode as the operator OLEG with the password MONDAY and connect to the database DEMODB:

> dbmcli -u OLEG,MONDAY -d DEMODB

dbmcli on DEMODB>

Start an SQL session for the database operator MONA with the password RED:

dbmcli on DEMODB> sql_connect MONA,RED

OK

More Information

Concepts of the Database System, SQL