ylnor ylnor - 1 month ago 5
MySQL Question

Stored Procedure returns different result than Query

I am trying to use a Mysql(MariDB) Stored-Procedure of a simple query with one parameter. However, the results of the invoked Procedure differs from the initial query, and I don't understand why.

Here is My initial Query:

MariaDB [(none)]> SELECT * FROM ob1.eco_serie WHERE TS_ID = 3;
+-----+-------+---------------------+---------------------+------+
| id | TS_ID | Date_period | Date_publi | Val |
+-----+-------+---------------------+---------------------+------+
| 4 | 3 | 1996-10-31 00:00:00 | 1996-11-01 00:00:00 | 50.5 |
| 5 | 3 | 1996-11-30 00:00:00 | 1996-12-02 00:00:00 | 53 |
| 6 | 3 | 1996-12-31 00:00:00 | 1997-01-02 00:00:00 | 55.2 |
... ... ........... ............. ...


Then I make a Stored-Procedure of this Query:

MariaDB [(none)]> CREATE PROCEDURE ob1.GET_eco_serie (IN par_serie_ID INT)
-> BEGIN
-> SELECT * FROM ob1.eco_serie WHERE TS_ID = par_serie_ID;
-> END//
Query OK, 0 rows affected (0.06 sec)


But, when I call this Procedure with the same parameters as before, I get an empty result:

MariaDB [(none)]> CALL ob1.GET_eco_serie(@3);
Empty set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)


Any idea what is going on here? Thanks.

Answer

call a procedure like this:

CALL ob1.GET_eco_serie(3);

Just remove @ sign