Jump to content

SQL Stored Procedure with MySQL don't work


Recommended Posts

Hello,

I am testing the principle of calling a stored procedure in Unilogic 1.33.236 but I have a visible error message in the structure associated with the request:

  • Status: -5 (Not documented in the Unilogic help)
  • Status report : 2031 no data supplied for parameters in prepared statement


I am working with a MySQL database. The connector is correctly configured.
In PhpMyAdmin, I created a stored procedure to insert data in a table with the name of the dynamic table as described in this link: https://support.unitronics.com/index.php?/selfhelp/view-article/sql-dynamic-table-name
but adapting it to MySQL.
Here is the code for the stored procedure:

DELIMITER $$
CREATE PROCEDURE `insert_data`(IN `idStation` INT, IN `ts` INT)
BEGIN
SET @varTable = CONCAT('bd_acquisition_',idStation);
SET @query = CONCAT('INSERT INTO ',@varTable,'(`id_station`, `date_time`) VALUES(',idStation,',FROM_UNIXTIME(',ts,'))');
PREPARE dynQuery FROM @query;
EXECUTE dynQuery;
DEALLOCATE PREPARE dynQuery;
END$$
DELIMITER ;


I tested the call in phpmyadmin

CALL insert_data(10,123456);

and it works fine.
I've tested the call in the LADDER code by giving input values in hardcodes directly in the SQL statement and it works very well (without checking "Is Executing Stored Procedure") But I'd like to provide the input values through the SQL Query block and that's where it gets stuck...The problem comes from the call with the placeholders. Nothing works: ? , :param , @param , With or without "Is Executing Stored Procedure".

Does anyone have any ideas?

Thanks in advance
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...