Skip to Content

database module under XS Advanced: SQL Update possible during build?

Hi,

under HANA XS Advanced, i'm working on a MTA project. I want to automatically manipulate the entries in one of my database tables during the build of the database module of the project. More specifically, i want to update the entries after they have been inserted - using hdbtabledata - but before the module is used by other modules. How can this be done?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jul 29, 2020 at 04:17 PM

    You can adjust the package.json of your db module and call your own script after the execution of:

    "start": "node node_modules/@sap/hdi-deploy/deploy.js",
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Stefan,

      when you add @sap/hana-client as a dependency you should have no issues connecting to the DB using the credentials provided via the environment. @sap/xsenv helps you to read this values.

      Have you tried:

      "start": "node node_modules/@sap/hdi-deploy/deploy.js && echo 'Start done'"

      ?

      Best regards
      Gregor

  • Posted on Aug 03, 2020 at 01:04 PM

    Hi Gregor,

    "... && echo 'Start done'" gives me an error "Build command failed: hdi-build operation failed: The start command must not contain \\' or '!"

    Interesting enough: I do not get this error with my above trial with "poststart".

    I just omited the single quotes and the project builds!

    Unfortunately, i still don't see any effects of my start script. I would have expected to see the "Start done" somewhere in the Web IDE Console.

    Furthermore, i created a stand-alone-script named "prep_db_tables.js" which uses @sap/hana-client to do an SQL-update on one of my tables. So far, i have not yet figured out how to use @sap/xsenv to get the credentials, but for a first test i simply put them in manually. The script works and the db entry gets updated. But when i put the same script in my Web IDE project, connect it to the start command via package-json and start the build process, the db entry does not get updated.

    Where am i going wrong?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.