title: HANA OData create procedure - where is my new ID?
body: <p>In my UI5 app, I have a list of items. I create a new item via a pop-up (enter some details and click OK). With my JSON data for the new entity, I then call 'create' on my OData model. The OData entity (as defined in my xsodata service) uses a stored proc to create db records, and uses a sequence to generate the next ID. Up to this point, all is well. The record is created, and my success callback is executed. However, what I now need is to have the new record's ID in my response payload, but I cannot manage to get it. Here is the JS code running the create, with the success/error callbacks:</p>
  
  <pre><code>// Update the model and add our new forecast
      this.getView().getModel().create('/Forecasts', oData, {
          success : jQuery.proxy(function(mResponse) {
              // nav to newly created Forecast
              this.getRouter().navTo("forecast", {
                  forecastId: mResponse.ID, // EMPTY!
                  tab: "data"
              }, false);
          }, this),
          error : jQuery.proxy(function(mResponse) {
              this.showErrorAlert("Problem creating new forecast");
          }, this)
      });
  </code></pre>
  
  <p>mResponse.ID is always empty. I figure, it shouldn't be. ID is defined as a key in the entity forecast.</p>
  
  <pre><code>@Catalog.tableType: #ROW
  entity forecast {
      key ID: IdType;
      NAME: NameType;
      CREATED: UTCDateTime;
      USER: UsernameType;
      EFFECTIVE: LocalDate;
      DAYS: Integer;  
  };
  </code></pre>
  
  <p>And the xsodata service (schema and namespace references removed):</p>
  
  <pre><code>service {
  
      // Forecasts
      "&lt;namesapce&gt;.data::models.forecast" as "Forecasts" 
      create using "&lt;namesapce&gt;.procedures::createForecast";
  }
  </code></pre>
  
  <p>Here is the stored proc, performing the insert:</p>
  
  <pre><code>PROCEDURE "&lt;schema&gt;"."&lt;namespace&gt;.procedures::createForecast" ( 
      IN intab "&lt;schema&gt;"."&lt;namespace&gt;.data::models.procedures.forecast",
      OUT outtab "&lt;schema&gt;"."&lt;namespace&gt;.data::models.procedures.errors"
  ) 
  LANGUAGE SQLSCRIPT
  SQL SECURITY INVOKER
  AS
  -- DEFAULT SCHEMA &lt;schema&gt;
  -- READS SQL DATA AS
  BEGIN
      DECLARE lv_name string;
      DECLARE lv_days integer;
  
      SELECT NAME, DAYS INTO lv_name, lv_days FROM :intab;
  
      -- Now validate and insert
      IF :lv_name = '' THEN
          outtab = SELECT 500 AS http_status_code,
                      'Empty Forecast name' AS error_message,
                      'The Forecast name cannot be empty' AS detail FROM dummy;
      ELSEIF :lv_days = 0 THEN
          outtab = SELECT 500 AS http_status_code,
                      'Empty Forecast days' AS error_message,
                      'The Forecast days cannot be empty' AS detail FROM dummy;
      ELSE
          -- Perform the INSERT
          INSERT INTO "&lt;namespace&gt;.data::models.forecast"
          VALUES ("&lt;namespace&gt;.data::forecast".NEXTVAL, 
                  lv_name,
                  CURRENT_TIMESTAMP,
                  CURRENT_USER,
                  CURRENT_DATE,
                  lv_days);
      END IF;
  END;
  </code></pre>
  
  <p>How do I get that NEXTVAL value (now CURRVAL) into my response payload, so it can be accessed in the success calback of the model's create function? I've tried multiple out tables, but encounter constant problems. Surely there is an easy way to do this? The key of the inserted record is paramount. I don't want to create the ID on the client side, as it won't be accurate - I need it to be returned from the INSERT.</p>