Skip to Content
-1

how to execute sql statement remotely on SAP HANA database instance

May 19, 2017 at 10:16 AM

66

avatar image

Hi,

I am trying to execute sql statement on SAP HANA database instance using the following bash script:

#!/bin/bash -ex PATH=$PATH:~/sap/neo/tools:~/sap/hdbclient # add console client and HANA client to PATH

user=mymail@example.com # TODO replace with your user ID account=mysubaccount # TODO replace with your subaccount ID dbSchema=myschema # TODO replace with your schema

json=$(neo.sh open-db-tunnel -h hanatrial.ondemand.com -a "$subaccount" -u "$user" -p "$HCP_PASSWORD" -i "$dbSchema" --background --output json) regex='.*"host":"([^"]*)".*"port": ([^,]*),.*"instanceNumber":"([^"]*)".*"dbUser":"([^"]*)".*"dbUserPassword":"([^" ]*)".*"sessionId":"([^"]*)".*' [[ $json =~ $regex ]] dbHost=${BASH_REMATCH[1]} dbPort=${BASH_REMATCH[2]} dbInstance=${BASH_REMATCH[3]} P U B L I C 157 dbUser=${BASH_REMATCH[4]} dbPassword=${BASH_REMATCH[5]} tunnelSessionId=${BASH_REMATCH[6]}

hdbsql -n "$dbHost:$dbPort" -i "$dbInstance" -u "$dbUser" -p "$dbPassword" "SELECT * FROM dummy" neo.sh close-db-tunnel --session-id $tunnelSessionId

i found the above piece of code in persistence service document and it is not working. i adjusted the values but even then it does not work.

can someone help?

Thanks

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers