cancel
Showing results for 
Search instead for 
Did you mean: 

How to return value in OData modification exit using SQLScript

arul_palanivelu
Explorer
0 Kudos

I am trying to write a xsodata service that uses a SQL script to create record into a table. How do I get back the primary key field that was generated in the procedure back to the caller.

For example the entity has two fields, ID integer and Name String(50).

The ID is generated using a sequence inside the procedure that is used to insert the record.

I want the caller to know about the id that got generated, how do I do that.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

arul_palanivelu
Explorer
0 Kudos

I just found the following text in the developer guide, so the question is not valid, I guess. However the text that says "the key must be included in the URL" is incorrect, it should be part of the body.

For CREATE requests, for example, to add a new entry to either a table or an SQL view exposed by an OData service, you must specify an explicit key (not a generated key); the key must be included in the URL as part of the CREATE request. For UPDATE and DELETE requests, you do not need to specify the key explicitly (and if you do, it will be ignored); the key is already known, since it is essential to specify which entry in the table or SQL view must be modified with the UPDATE or DELETE request.

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You can accomplish what you describe but only as of SP7 and with the new XSJS exits in the XSODATA framework. SQLScript exits allow you to use a sequence but then you can't pass back the generated key in the response object.  You would still see the dummy key which was passed in.  XSJS doesn't have this limitation and allows you to use a sequence (or any other data changes) and pass them back in the response.