Skip to Content
1
Oct 18, 2020 at 07:50 AM

Unable to create users in Hana Database Using execBatch()

151 Views Last edit Oct 19, 2020 at 12:28 PM 2 rev

I have an XSA System and XSA Database User. This XSA DB user will be used to create new Hana database users in XSA. I am trying to create a batch of users with the help of execBatch() functionality. I have a cap with node.js project.

I am executing sql queries in my node.js file. Below is the code.

createusersarr is the array which contains the list of users to be created. The array looks like this -

[ [ 'SAC_XSA_HDB_USER_ABC1' ], [ 'SAC_XSA_HDB_USER_ABC2' ], [ 'SAC_XSA_HDB_USER_ABC3' ], [ 'SAC_XSA_HDB_USER_ABC4' ], [ 'SAC_XSA_HDB_USER_ABC5' ], [ 'SAC_XSA_HDB_USER_ABC6' ], [ 'SAC_XSA_HDB_USER_ABC7' ], [ 'SAC_XSA_HDB_USER_ABC8' ], [ 'SAC_XSA_HDB_USER_ABC9' ], [ 'SAC_XSA_HDB_USER_ABC10' ] ]

When I run my node app,

It doesnt create the users and the error shown is undefined as below -

ERROR - Targeting User Creation

undefined

I am not sure why this is failing? It runs fine when I use exec() instead of execBatch() and provide user name one by one in the create user query (basic loop mechanism).

console.log("Targeting User Creation")
            try{
                let createuserstatement = await xsaDbConn.preparePromisified("CREATE USER ? PASSWORD AbcYes NO FORCE_FIRST_PASSWORD_CHANGE")
                await createuserstatement.execBatch(createusersarr)
                console.log(`Users created.`) 
            }catch(err){
                console.log(err.stack)
            }