Call Stored Procedure with return value

0
Hey community,   I connected my app to a external database. Reading the data and displaying/storing in my app is no problem and works perfectly. Therefore I'm using the "Database Connector" module: Mendix Marketplace - Database Connector   Now I'm trying to call a stored procedure and get a single integer value back from it. Calling that procedure would be easy with the module, but I can't figure out how to get return values, or output parameters set up.  Strangely there is an ENUM called "ParameterMode" with values "INPUT" and "OUTPUT" in that module and you need to set the ParameterMode on each parameter of your statement, but it doesn't change anything in how the query works, or if I get a value back.   I also tried using the "External Database Connector" module: Mendix Marketplace - External Database Connector but no success with that either, it can't even call parameterized procedures with that one, not to mention return values.   I'm trying to build this in Mendix 10.11.0 (which is not selectable when creating questions ok?) and trying to connect to a MySQL database.   Hope anyone has done a similar thing and can tell me how to get that integer return value saved in the app.
asked
1 answers
1

Hi Syman,

I found the solution in the domain model of the DatabaseConnector module. There it says: "After calling the statement, values in OUT or INOUT parameters are set and can be read."

So just take a look at the parameter which has the mode "OUTPUT" AFTER you have called your stored procedure. It then should hold the value returned by your stored procedure.

In case you are working with a list of parameters you need to cast the parameter to its correct type to make the "Value" attribute available, in your case its the "ParameterLong" object to which you need to cast your parameter to.

Hope this answer helps you, let me know if you need any iadditional help.

answered