I use a lot of MySQL stored procedures in my work. Often I want to return a value after running a stored procedure, and I would really appreciate Server Actions giving me access to a stored procedure’s out value.
A common way to do this in MySQL is like this:
-- test_out(input_string, output_string)
CALL test_out("Hello", @the_output);
SELECT @the_output AS returned_value;
Which in MySQL Workbench, gives me the result I expect:
So I am trying to replicate this structure within a custom database query. After a lot of attempts at how to format the query, Wappler will let me save this format:
Am i right in saying the SELECT needs to be outside of the procedure for Wappler to pick up the results?
So you would pass something unique into the stored procedure, have that value be one of the fields of the record you INSERT into the database, and then use that unique key to do a SELECT and find that record after the stored procedure has finished?
You can set a variable and the select it, which will be available in Wappler.
EDIT:
And if you are doing an insert, you can do something like this
insert into table1 set field2 = 'test'; # insert a record
SET @random = 'random string'; # if you need some other value
SET @lastInsert = LAST_INSERT_ID(); # the primary key of the table
select @random, @lastInsert; # send them both to Wappler custom query