I have the following question, how can I execute a procedure that receives an input parameter?
Try the following way:
const sql = CALL insert_data(?);
const result = await query(sql, [dataJson]);
But I get the following error message:
Error] Error: Incorrect arguments to mysqld_stmt_execute.
Hey, I guess you used the Create Procedure statement, which I didn't mention in my post.
In any case, if you created a procedure with one parameter, all you need is to use
constresult=awaitquery(sql,[value]);
The first argument is the SQL query,
The second argument is a flat array with all the values in the same order as '?' marks.
The value should be simple, like string, int, and so on.
Hey Julia, Thanks for the precise guide.
I have the following question, how can I execute a procedure that receives an input parameter?
Try the following way:
const sql =
CALL insert_data(?)
;const result = await query(sql, [dataJson]);
But I get the following error message:
Error] Error: Incorrect arguments to mysqld_stmt_execute.
Hey, I guess you used the Create Procedure statement, which I didn't mention in my post.
In any case, if you created a procedure with one parameter, all you need is to use
For example:
Create Procedure:
Add a method in user.model.js file, which uses the call command:
Thanks Julia for your response and explanation, I could solve my problem.
Hi Julia.
I have to execute a procedure that returns an output parameter. How can I get that value ?