## Executing a Single Database Statement

### Use

You use the DBM command db_execute to execute a database statement. The database session required for this is implicitly opened by the Database Manager during execution of the database statement and then closed. To open a database session implicitly, the Database Manager uses the data for the first DBM operator. For this reason, only those database statements for which the first DBM operator is authorized can be executed in this way.

The database session is always opened in AUTOCOMMIT mode. This means that executed SQL statements are automatically closed with a COMMIT statement and thus can no longer be rolled back with a ROLLBACK statement.

If you use db_execute, the generated result set may exceed the size of the reply package (approx. 16 KB). If you see the keyword CONTINUE at the end of the output, this tells you that more data records have been found and can be called. In this case, you have to proceed as described in Executing a Succession of Database Statements since you will have to execute further database statements in the same database session to display the rest of the result set.

If you so desire, you can have the result set displayed record-by-record instead of having the entire result set output. As this requires you execute further database statements in the same database session, in this case, too, proceed as described in Executing a Succession of Database Statements.

To read the prerequisites, see Database Manager CLI, db_execute

See also:

Glossary, AUTOCOMMIT Mode, ROLLBACK

### Scenario

You want to execute the SQL statement for displaying the contents of table users and display the largest-possible number of data records in the reply.

### Procedure

Log on to the Database Manager CLI as operator OLEG with password MONDAY, connect to the database instance DEMODB, execute the SQL statement for displaying the contents of table users (user name, connection mode and user ID):

>dbmcli -u OLEG,MONDAY -d DEMODB db_execute SELECT username,connectmode,user_id from users

OK

END

'DBM';'MULTIPLE';22

'OLEG';'MULTIPLE';0

'DBADMIN';'MULTIPLE';10

'MONA';'MULTIPLE';24