Why doesn't the stored procedure call return anything?
I made a stored procedure with a parameter. When I call this procedure without error, I am not shown any results. What's wrong with this code?
drop PROCEDURE if exists `getUsersByContact`;
delimiter $$
Create PROCEDURE `getUsersByContact`(
IN contact1 VARCHAR(10)
)
BEGIN
SELECT id,name FROM tbl_user WHERE contact = contact1;
END $$
delimiter ;
When I call it
call getUsersByContact('9999999999');
It doesn't return any rows and there is no error in phpmyadmin. However, when I use the out parameter and call the stored procedure and select that variable, it works fine. I have also tried this link and this link .
+3
user2896261
source
to share
2 answers
When running a request inside SP, It will work!
SELECT id,name
FROM tbl_user
WHERE contact = `contactname`;
But this one won't work.
SELECT id,name
FROM tbl_user
WHERE contact = contact1;
You can find the reason here: http://mysqldb.bigresource.com/SELECT-INTO-returns-null-in-Stored-Procedure-Jx95y6IPJ.html
0
source to share