cancel
Showing results for 
Search instead for 
Did you mean: 

XSOData Post return ID

roberto_falk
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate

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. 

roberto_falk
Participant
0 Kudos

Hi Thomas,

Thanks, worked using the before create event.

Maybe an idea for the future would be to add the row parameter as INOUT... not sure aout the impact on the system, just an idea to be able to also use procedures.

Thanks again.

Roberto Falk

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Stored procedures in HANA have no concept of IN/OUT parameter yet. This is a request in the product backlog.  As soon as stored procedures support IN/OUT parameters we plan to adjust the XSODATA exits to use this.

roberto_falk
Participant
0 Kudos

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

Answers (1)

Answers (1)

gregorw
Active Contributor
0 Kudos

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

roberto_falk
Participant
0 Kudos

HI Gregor,

not sure about SP9, but on SP8, that your are using, the only way is through xsjs instead of procedures. Currently in my projects I'm using xsjs to call the sequences and retorn the id.

best regards,

Roberto Falk

Former Member
0 Kudos

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.