cancel
Showing results for 
Search instead for 
Did you mean: 

CAP multi tenant app : How to call a stored procedure with table parameter through @sap/hdbext ?

achim_vogel2
Explorer
0 Kudos
760

Hello experts,

I try to call a store procedure with table parameters in a cap SaaS multitenant app, which uses the service manager to manage the HANA containers. I would like to call the procedure with @sap/hdbext to have the benefit of easy use of table parameters.

In https://developers.sap.com/tutorials/hana-cloud-cap-stored-proc.html Thomas Jung describes the call of a stored procedure in a cap cds service implementation in a single tenant environment:

const cds = require('@sap/cds')

module.exports = cds.service.impl(function () {
  this.on('sleep', async () => {
    try {
           const db = await cds.connect.to('db')
           const dbClass = require("sap-hdbext-promisfied")
           let dbConn = new dbClass(await dbClass.createConnection(db.options.credentials))
           const hdbext = require("@sap/hdbext")
           const sp = await dbConn.loadProcedurePromisified(hdbext, null, 'sleep')
           const output = await dbConn.callProcedurePromisified(sp, [])
           console.log(output.results)
            return true
      } catch (error) {
           console.error(error)
           return false
      }
  })
})

In the multitenant app I do not now how to get necessary options for createConnection from the service manager.

Do somebody know how to integrate @sap/hdbext with the service manager in a multitenant app?

Are the HANA config/credential options of the tenants HANA container available in cds.tx(req) ?

Thanks

Achim

SamueleBarzaghi
Participant
0 Kudos

Hi achimvogel0264,

Do you have an answer to this question?

Thanks

Best Regards,

Sam

achim_vogel2
Explorer
0 Kudos

Hi Sam,

no, not until now.

Best regards

Achim

former_member814837
Discoverer
0 Kudos

Hi Achim,

Have been able find a solution here?

Regards,

Arpitha

View Entire Topic
achim_vogel2
Explorer
0 Kudos

I have created my own GLOBAL TEMPORARY COLUMN TABLE in HANA and fill the data into the temporary table before calling the procedure by cds.run (`CALL <procedureName>()',[]);

I do no longer use @sap/hdbext.