Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Manage multi-table insert using OData Service

$
0
0

Hi Thomas,

 

After long time of effort I have decided break it down my task into two

 

1. test whether XSJSLIB code is working properly

2. test it with batch option

 

I have made some progress on step 1. I am trying to insert record in Person Table and good thing is I am able to debug my XSJSLIB and sequence is getting generated and record is also getting inserted but not correct values.

 

Now let me explain about but part of it.

 

Request body is :

 

{

  "PERS_ID":"0000000000",

  "FIRSTNAME":"test from service",

  "LASTNAME":"Test from Service",

  "E_MAIL":"testfromservice@gmail.com"

}


XSJSLIB exit code :


function person_create_before_exit(param) { 

     let after = param.afterTableName; 

      var pStmt; 

      try { 

       pStmt = param.connection.prepareStatement('select "ZCUSTSEARCH"."PERSON_ID_SEQ".NEXTVAL from dummy'); 

       var rs = pStmt.executeQuery(); 

       var person_id = ''; 

       while (rs.next()) { 

       person_id = rs.getString(1); 

       } 

       pStmt.close(); 

    

      

       pStmt = param.connection.prepareStatement('update "' + after 

         //  + '" set PERS_ID = "' + person_id

          // + ' " ,' + 

       + '" set "PERS_ID" = ?,' + 

            '  FIRSTNAME = ?, ' + 

            '  LASTNAME = ?,' + 

            '  E_MAIL = ?');

       pStmt.setString(1, person_id); 

       pStmt.setString(2, 'DHARMESH'); 

       pStmt.setString(3, 'PUROHIT'); 

       pStmt.setString(4, 'DHARMESH.PUROHIT@GMAIL.COM'); 

 

       pStmt.execute();

       pStmt.close(); 

      } 

      catch (e) {

    

      } 

    }

 

Now issue is when I insert record sequence is getting generated properly but while inserting record other values are not getting inserted what I have in request body. I am seeing values which I have in my xsjslib code :  which is as following

      pStmt.setString(1, person_id); 

       pStmt.setString(2, 'DHARMESH'); 

       pStmt.setString(3, 'PUROHIT'); 

       pStmt.setString(4, 'DHARMESH.PUROHIT@GMAIL.COM');

 

any idea what am I missing?

 

 

Regards,

 

Dharmesh


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>