First Steps with SAP DB

Setting the environment

  1. Execute the script sapdbenv to set the environment.
    . sapdbenv.sh
    If you have downloaded firststeps.tgz from www.sapdb.org, you'll have to call it as
    . sapdbenv.sh <indep_path> <dep_path>

Starting and stopping the database

  1. Is the database running?
    $ dbmcli -d TST -u DBM,DBM db_state
    Output  
    OK
    State
    ONLINE
    ONLINE state:
    (the database is accepting connections)
    OK
    State
    ADMIN
    ADMIN state:
    (the database is accepting only administration requests
    OK
    State
    OFFLINE
    OFFLINE state:
    (the database is not started)
    ERR
    ...
    some error occurred
    (was the dabase name and the user spelled correctly?)

    After installation, the demo database should be in in state WARM.

  2. Stopping the database
    $ dbmcli -d TST -u DBM,DBM db_offline
    Output  
    OK the database has been stopped
    ERR
    ...
    some error occurred

    All databases should be stopped using this command before a shutdown. Otherwise, loss of data may occurr.

  3. Starting the database
    $ dbmcli -d TST -u DBM,DBM db_warm
    Output  
    OK the database has been started
    ERR
    ...
    some error occurred

  4. Troubleshooting

Executing SQL

  1. Starting ireport
    $ ireport.py -d TST -u TEST,TEST
    Output  
    SAP DB Terminal Report 0.1
    Type 'help' for help.
    An empty line repeats the last command
    ==>
    You may enter SQL commands
    Traceback (innermost last):
    ...
    sapdb.CommunicationError: sapdb.CommunicationError: [1] database not running
    the database must be started
    Traceback (innermost last):
    ...
    sapdb.SQLError: sapdb.SQLError: [-4008] Unknown user name/password combination
    the username or password was misspelled

  2. Executing simple SQL
    ==> select 'Hello, SAP DB' from dual
    Output  
    |Hello, SAP DB|
    ==>
    the statement has been executed successfully
    sapdb.SQLError: some SQL error occurred

  3. Scrolling through result sets
    When the resulting rows will not fit onto the screen, ireport.py allows to scroll through the result set
    ==> select * from messages
    Output  
    |-99999|ENG|PRECOM ENGMSG 7.2.0.00 1998-02-27|
    |-31000|ENG|Gateway DB error:|
    ... more result lines ...
    ==>
    the statement has been executed successfully
    sapdb.SQLError: some SQL error occurred

    ==> next
    The next lines of the result set will be displayed. The exact number of lines depends on the value of $LINES.
    The commands for navigating through the result set are

    $ ireport.py -d TST -u TEST,TEST -tutorial
    will guide you through a short tutorial.

  4. Using a SQL tutorial
    If you are unfamiliar with SQL, there are several SQL Tutorials on the Web. Many of those were written with Oracle (tm) in mind.
    $ ireport.py -d TST -u TEST,TEST -oracle
    will connect  to SAP DB in an Oracle compatible mode. All of the programming interfaces of SAP DB allow this Oracle compatibility mode.

Where to go from here