jung-thomas / sap-hdbext-promisfied

Moved to https://github.com/SAP-samples/hana-hdbext-promisfied-example
https://github.com/SAP-samples/hana-hdbext-promisfied-example
Apache License 2.0
2 stars 1 forks source link

Call procedure not working with params table type #4

Closed luizcarlospedrosogomes closed 1 year ago

luizcarlospedrosogomes commented 1 year ago

define procedure image

call procedure image

error image

package.json image

jung-thomas commented 1 year ago

The error message seems to be valid. Your Stored Procedure is using table types for the parameters (DB_CLIENTS). But you are passing scalar values into the interface. As the error says you need to pass tables not scalar based upon your procedure interface.

luizcarlospedrosogomes commented 1 year ago

Thank you for the answer.

I wasn't very happy with the above code example, in fact I've been trying several options, I believe the most coherent would be this:

 let dados   = insertData.slice(0,2);
  const schema = 'EA4E07F4D0A6485DABFE1A097EC113F3';

            const dbProcedure = "upload";
            const inputParams = {DADOS: dados, RESULT: ?}
            let db = new dbClass(await dbClass.createConnectionFromEnv())
            let sp = await db.preparePromisified(`CALL ${schema}.${dbProcedure}(?,?)`)
       //     let sp = await db.loadProcedurePromisified(schema, dbProcedure)
            let result = await db.callProcedurePromisified(sp, inputParams)

but even this code gives the same error.

would you have an example of this besides the sleep procedure? and in addition to the example that exist in this repository?

jung-thomas commented 1 year ago

I don't know what you are trying to write here, but an issue in this repo isn't really appropriate. if you are just trying to get advice on how to call a HANA Stored Procedure, you should ask that question on the SAP Community Q&A. I looked at your Stored Procedure code and I don't understand why you are using table input parameter. You'd be passing large amounts of data from the frontend to the backend. Your insertData.slice isn't going to create a JSON array which is what would be expected as a input parameter of a table. Your still passing a scalar value.

This package is just a promisified wrapper around the standard @sap/hdbext. Your question isn't really related to the promises aspects. Prhaps you need to look at the underlying library (@sap/hdbext) documentation on how to pass in table parameters if that is in fact what you need to do. https://www.npmjs.com/package/@sap/hdbext