Background documentationsql_execute Locate this document in the navigation structure

 

Use this DBM command to transfer an SQL statement to the database.

Unlike the sql_executenice DBM command, in the reply to this command as many data records as possible are displayed. The quantity of data transferred is limited by the size of the reply package transferred by the DBM server.

With SELECT statements, the system displays the data records of the reply. If not all the data can be displayed because of the limited reply package size, you can use the sql_fetch DBM command to transfer another reply package containing data records. However, this is only possible if you are still in the same database session.

If you specify other SQL statements, the execution of the statement is confirmed with an OK message.

When you execute this command, it implicitly opens a session with the database and ends the session as soon as the command has been executed. This database session is opened in AUTOCOMMIT mode, in other words, each SQL statement you execute is automatically completed with a COMMIT statement.

Recommendation Recommendation

If a series of SQL statements is to be executed and the statements can only be executed by a particular database user, first start an SQL session with the data of this database user (see:sql_connect), execute all SQL statements, and then close either the SQL session (see: sql_release) or Database Manager CLI.

End of the recommendation.

For more information about SQL statements, see the SQL Reference Manual and SQL Tutorial.

Prerequisites

  • You are working in the session mode of Database Manager CLI.

Structure

sql_execute [<user_type>] <statement>

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

Options
Options

Option

Description

<statement>

SQL statement

<dabase_user>

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: the first DBM operator

DBA: database system administrator

SAP: special database user in connection with SAP applications

Result

OK

[END|CONTINUE]

[<record>

<record>

...]

Values for the Reply Fields

Value

Description

END

The complete reply was output.

CONTINUE

More data records are available but were not transferred due to the limited size of the reply package.

<record>

Result data of the SQL statements

The fields in a data record are separated by semicolons. Character strings are output in single quotation marks.

In the event of errors, see Reply Format.

Example

Call Database Manager CLI in session mode, log on as the operator OLEG with the password MONDAY, connect to the database DEMODB, and display the columns of the USERS table with their associated comments:

>dbmcli -u OLEG,MONDAY -d DEMODB

dbmcli on DEMODB>sql_execute SELECT columnname, comment FROM domain.columns WHERE tablename = 'USERS'

OK

END

'OWNER';(LOB)

'GROUPNAME';(LOB)

'USERNAME';(LOB)

'USERMODE';(LOB)

'CONNECTMODE';(LOB)

'MAXTIMEOUT';(LOB)

'COSTWARNING';(LOB)

'COSTLIMIT';(LOB)

'DEFAULTCODE';(LOB)

'CREATEDATE';(LOB)

'CREATETIME';(LOB)

'ALTERDATE';(LOB)

'ALTERTIME';(LOB)

'PWCREADATE';(LOB)

'PWCREATIME';(LOB)

'SERVERDB';(LOB)

'SERVERNODE';(LOB)

'USER_ID';(LOB)

'ISREPLICATIONUSER';(LOB)

'COMMENT';(LOB)

More Information

Concepts of the Database System, SQL