Skip to Content
avatar image
Former Member

HANA 2.0 - Create table from Node.js module with hdbext

Hello everyone,
I am experiencing the most common error but I am not able to understand why I am falling into that.
Maybe I am missing a very simple point, but here's the scenario:

I have a Node.js module running in an HANA 2.0SPS01 application which is connecting to an external - non HANA - OData Service, loads the metadata for specific entities and tries to create table(s) on the fly which reflect the structure of the requested entities.

After that, it loads data from the service and stores fetched data inside table(s) created in step 1.

For that, I am using the "normal" sap-hdbext standard module providing DDL statements to create the tables I need.
Notice that I am using the hdb-ext middleware, to have the hdb module injected and available to each request.

        // Setup HDB Client:
        app.use(xsHdb.middleware(xsEnv.getServices({
            hana: process.env.HANA_SERVICE_NAME || {
                tag: "hana"
            }
        }).hana));

However, everytime I invoke the db.exec() method by providing the DDL statement (which is something like CREATE TABLE "<Context>.<TableName>" (<Columns>)...) I always receive a "Insufficient privileges: Unauthorized" error.

The schema name is not specified, as it's determination is part of the hdb-ext module loading, as well as the connection to the database which is automatically created by the module using the HDI container technical user.

What could be the reason of the authorization issue? The client is perfectly able to execute DML statements, but no DDL ones.

Is there something I am missing/forgetting while working with HDI containers?

Thanks,

Roberto.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jul 12, 2017 at 12:10 AM

    Hello Roberto:

    I wonder if you need to add a create table privilege to your hdbrole. Step 9 of this tutorial, https://www.sap.com/developer/tutorials/xsa-hdi-module.html, might be of help.

    Regards,

    Carl

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Carl,
      Thanks for pointing this out, I forgot to add the "CREATE" privilege in the list of admin privileges.

      It works as expected.

      Cheers,
      Roberto.