cancel
Showing results for 
Search instead for 
Did you mean: 

How to run native SQL in SAP system based on MaxDB

former_member443045
Discoverer
0 Kudos

How to run native SQL in SAP system based on MaxDB?

In ST04->Tools->Database Manager(CLI), I always get some error to run very simple SQL: e.g.

C70>ERR=    -24977

ERR_COMMAND: Unknown DBM command "select

Name and Server     : C70 - iwdfvm2444

DBMRFC Function     : DBM_EXECUTE

Command             :  select count(*) from CRMD_ORDERADM_H

Error               : DBM Error

Return Code         :     -24977

Error Message       : ERR_COMMAND: Unknown DBM command "select

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

yashwanthkumar_kethineed
Active Participant
0 Kudos

Hi Edward,

The Database Manager CLI (DBMCLI) is a database tool that can be used to administer database.

The tool allows you to create, monitor, back up, and restore databases.

However you can execute SQL statements in DBMCLI if you are logged in as SYSDBA user or SCHEMA user who is the owner of the data you are trying to query. You need to use "sql_execute" in front of your sql statement.

Ex:  sql_execute select count(*) from CRMD_ORDERADM_H

There is another tool called "SQLCLI"

SAP MaxDB SQLCLI is a command line tool for entering and executing SQL statements, executing database procedures, and querying information about SAP MaxDB databases.

Connect to the DB using the SQLCLI tool

For ex: "C:\sapdb\programs\bin\sqlcli -d DEMODB -u MONA,RED -S INTERNAL"

sqlcli=>select CNO,TITLE,FIRSTNAME,NAME,ZIP from HOTEL.CUSTOMER

For other tools and more information refer to the TOOLS section of the SAP MaxDB documentation at http://maxdb.sap.com/documentation/

Hope this helps. Let me know if you have any questions.

Regards,

Yashwanth

former_member443045
Discoverer
0 Kudos

Hi Yashwanth,

Thanks a lot for your clear answer

However, I have got another error while runing the SQL below:

sql_execute select count(*) from SAPC70.CRMD_ORDERADM_H

C70>ERR=    -24988
ERR_SQL: SQL error
-4004,Unknown table n
Name and Server     : C70 - iwdfvm2444
DBMRFC Function     : DBM_EXECUTE
Command             :  sql_execute select count(*) from SAPC70.CRMD_ORDERADM_H
Error               : DBM Error
Return Code         :     -24988
Error Message       : ERR_SQL: SQL error
-4004,Unknown table n

-4004,Unknown table name:CRMD_ORDERADM_H

I have double checked the schema and table name, both are correct. Would you know the possible reason?

Again, thank you!

Regards,

Edward

yashwanthkumar_kethineed
Active Participant
0 Kudos

Hi Edward,

It would be good to check if you are able to run this sql statement from the command line

Go to command line of the database server

Connect to the database using SAPC70 user as follows

          sqlcli -d C70 -u SAPC70,<password>

          sqlcli C70=> select count(*) from SAPC70.CRMD_ORDERADM_H

It is always recommended to use the "SQL STUDIO" or "SQLCLI" tool for running the sql statements.

You can also double check this table contents and owner of this table from the SAP system in DB50 transaction under

Diagnostics > Database Objects > Tables/Views/Synonyms

Hope this helps.

Regards,

Yashwanth

Answers (0)