Procedure documentationExecuting Commands Locate this document in the navigation structure

 

You can use SQLCLI to execute SQL statements, database procedures and special SQLCLI commands.

Prerequisites

Some commands require you to be logged on to the database.

More information: Logging On to a Database

Procedure

Executing an Individual Command in Interactive Mode (Session Mode)
  1. Call SQLCLI:

    sqlcli [<options>]

    More information: Overview of All SQLCLI Call Options

  2. Enter the command.

    <command>

    Note Note

    You can also enter commands in multiple line mode or edit commands in an external file.

    More information:

    End of the note.

    Example Example

    You start SQLCLI and log on to the DEMODB database as user MONA with the password RED:

    sqlcli -d DEMODB -u MONA,RED

    You display general information about the database:

    \s

    host: localhost

    database : demodb

    xuserkey :

    user: MONA

    kernel version: KERNEL 7.6.00 BUILD 009-103-092-269

    sapdbc version: libSQLDBC 7.6.0 BUILD 009-103-092-248

    unicode : NO

    default code : ASCII

    sql mode : INTERNAL

    autocommit : ON

    End of the example.

More information:

Executing an Individual Command in Command Mode

Call SQLCLI and enter the command directly.

sqlcli [<options>] <command>

Example Example

sqlcli -d DEMODB -u MONA,RED \s

End of the example.

If you want to enter an SQL statement or a database procedure as a command, place the SQL statement or database procedure in quotation marks.

Example Example

sqlcli -d DEMODB -u MONA,RED "select CNO,TITLE,FIRSTNAME,NAME,ZIP from HOTEL.CUSTOMER"

SQLCLI executes the command and then exits.

End of the example.
Executing Several Commands from a Batch File
  • If you are in interactive mode, enter the path and name of the batch <file> from which SQLCLI is to import the command as follows:

    \i <file>

    More information: Batch File

  • If you are working in command mode, enter the path and name of the batch <file> when you log on to the database as follows:

    sqlcli [<options>] -i <file>