Skip to Content

XSOData Post return ID

Hi Colleagues,

I've created a xsodata service, and since I'm using a sequence to control the primary key, I've created a procedure to insert the information, calling the sequence.NEXTVAL when doing the insert.

In the header of the procedure I have two parameters (one IN and one OUT), The first parameter (IN) is the row itself, with the information that I need to insert, and the other parameter (OUT) is the error table, to get possible error messages.

Another remark is that, since when doing the post I need to inform all fields, I always perform the post setting ZERO in the ID.

The question is, can I somehow, receive the ID of the record inserted as the result/return of the post?

One idea was to set the ID in the row parameter, but since the row parameter is IN, I cannot modify it...

Thanks and regards,

Roberto Falk

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on Aug 05, 2014 at 09:52 PM

    If you want to update the ID and have it returned through the ODATA Response, you should use XSJS exits and not SQLScript Procedure exits.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Thomas,

      in fact, we have INOUT parameters, but just scalar parameters are supported. Table types, which is the case here, is not allowed.

      Funny, I'm a local HANA instructor here and I've always taught this (INOUT parameters) without really test it / use it. Now I had to test it, for the first time 😊.

      Thanks again for your help.

      Roberto Falk

  • Posted on Apr 12, 2015 at 09:10 AM

    Hi Roberto and Thomas,

    I face the same issue when using a stored procedure with hdbsequences to create new entries via my XSODATA service using a HTTP POST. I expect the new created ID in the result, but I only get the ID that I had to provide to make the input valid. I'm using the HCP Trial which is currently on HANA 1.00.85.00.397590. Any suggestions / solutions?


    Best regards

    Gregor

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Roberto Falk

      Hi,

      Can you post the sample code of how you did this ?

      I have the same situation.

      - POST over XS ODATA and processing in stored procedure.

      - IN & OUT defined but OUT is defined as error table.

      How can I return the newly created ID to the XS ODATA return without setting it in the error tab (which generated a 400 return).

      This post has tought me to use XSJS exit but i'm not sure how to use this.