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
  • I tried to duplicate the book sample code listed under the documentation (Appendix A), it returns following text rather than the expected book columns and sum cost. Wondering if the function piece of the storedprocedure is broken in latest release(16.3)?
    Value : Use the Execute Stored Procedure Smart Service to modify data. This function must only be used to query data, not modify.
  • Hello,

    we are having the same message "Use the Execute Stored Procedure Smart Service to modify data...etc",
    when using in SAIL the stored procedure described in the pdf here attached: link on forum

    Please note that :

    - the same procedure used in Smart Service works fine.
    - if we simplify the stored procedure, removing the select that is giving the result set, it works fine again in SAIL.

    We are using Appian 16.3 with MySql 5.7  on Ubuntu 14.04.

    Do you have any suggestion about?

    Thanks in advance, regards.
    Paolo

  • 0
    Certified Lead Developer
    in reply to paolos
    Hi Paolo,

    You will be unable to call stored procedures that modify data from SAIL, you can only call these kinds of stored procedures with a smart service. fn!executestoredprocedure() actively checks the stored procedure for any updates and returns the error you see if it finds any.
  • I do not understand why you say "stored procedures that modify data".

    In fact - in my understanding -  this simple stored procedure does not modify anything, it just return (if any) a set of rows.

    Am I missing something?

    Thanks again, regards.

  • 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

Reply
  • 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

Children
No Data