fn!executestoredprocedure error

simple expression rule using fn!executestoredprocedure gives me "java.lang.Integer cannot be cast to java.lang.Long" error, while smart service works fine in process model.

SP code:
CREATE PROCEDURE SCL_SumContract_Dealer (
IN dealer_id int,
OUT total_value int
)
BEGIN
          SELECT SUM(price) INTO total_value FROM contract
          WHERE contractstatus_status_id = 1 AND dealer_dealer_id = dealer_id;
END

OriginalPostID-255998


test_sp.txt

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to paolos

    It's hard to say without viewing the contents of your stored procedure, but if you are getting the error message "Use the Execute Stored Procedure Smart Service to modify data...etc" then the plugin thinks you are trying to update data. Here is the relevant snippet from ExecuteStoredProcedureFunction.java

    // Loop through results (make sure user isn't writing data, rollback if so)
            while (true) {
              if (call.getMoreResults()) {
                resultList.add(getProcedureResultSet(call, tf, procedureName));
              } else if (call.getUpdateCount() > 0) {
                conn.rollback(save);
                returnValue.put("success", tf.createBoolean(false));
                returnValue.put(
                  "error",
                  tf.createString(
                    "Use the Execute Stored Procedure Smart Service to modify data. This function must only be used to query data, not modify."));
                returnValue.put("parameters", emptyResults);
                returnValue.put("result", emptyResults);
                return tf.toTypedValue(returnValue);
              } else if (call.getUpdateCount() < 0) {
                // nothing else to process
                break;
              }
            }

  • I am sure this procedure does not modify anything because this is from the example in the attached pdf in this page:

    forum.appian.com/.../summary

    The direct link to pdf (see appendix A) is the following:

    forum.appian.com/.../o
  • 0
    Certified Lead Developer
    in reply to paolos
    I recommend debugging on a local machine to see what "call.getUpdateCount()" (line 5 in the snippet above) returns with your case.
  • I think I have found a workaround to make working the stuff.

    The code in example provided was like the following one, and the SAIL code was not working
    (please note the order of select statements)

    SELECT title, author, quantity, price FROM books WHERE title LIKE title_search;
    SELECT SUM(quantity * price) INTO total_cost FROM books WHERE title LIKE title_search;

    Well I've just changed the order of select statements, like the following, and now SAIL code works!

    -- first the select for calculation
    SELECT SUM(quantity * price) INTO total_cost FROM books WHERE title LIKE title_search;
    -- then the select for putting rows
    SELECT title, author, quantity, price FROM books WHERE title LIKE title_search;

    Hope this can help someone.

    Bye, Paolo