Does Select Query Support execBatch() in HANA?

361 views Asked by At

I am doing local development for SAP CAP with Nodejs project in VSCODE. I am connected to XSA Server. I am trying to create hana database user in XSA environment. I want to first check if the list of users that my app will create is already existing or not. For that, I am trying to execute a select query with where clause. Its a prepared statement, which i am trying to execute with execBatch(array). Below is the code.

let arr = [["POC_ADMIN_DEMO_USER_7"],["POC_ADMIN_DEMO_USER_1"]]
const checkuserexiststatement = await xsaDbConn.preparePromisified("SELECT USER_NAME FROM USERS WHERE USER_NAME = ?")
let readuserresult = await checkuserexiststatement.execBatch(arr)
console.table(readuserresult)

The execution of the query fails with the following error - Error

    Error: SQL command would generate a result set at 
C:\Users\Documents\XSA\SAC_POC\cap_njs\cap_njs\user_management.js.createUsers 
    (C:\Users\Documents\XSA\SAC_POC\cap_njs\cap_njs\user_management.js:59:60)

I want to know if select query/statement supports execBatch() functionality in Hana as the same select statement works without any placeholder that is when the value of the user_name is provided directly in the where clause and exec() used instead of execBatch(), Or is it that I am missing some point here?

1

There are 1 answers

0
Shreyasi Chakraborty On BEST ANSWER

execBatch() - returns no of rows affected as a result of the query executed. Select query returns a result set (if any) or else an empty array in Node.js. Therefore execBatch() is not compatible with Select query because execBatch() is used for batch execution and selection is one shot instead of batch.