简体   繁体   中英

MySQL query does not execute if i use the Stored Procedure parameter in the query

I am creating a very simple store procedure with a query, but when i use the store procedure IN parameter in the query it gets stuck and does not execute the query, but if i put the value direct to the query it works.

This works:

CREATE PROCEDURE `cap-reports`.ffap_test()
BEGIN
     select * FROM students WHERE name='Fernando';
END

This does not, i spent 10 minutes and it never returned

CREATE PROCEDURE `cap-reports`.ffap_test(IN pName VARCHAR(10))
BEGIN 
    select * FROM students WHERE name=pName;
END

call `cap-reports`.ffap_test('Fernando');

What mistake i am doing here? I never had this problem before

This procedure works for me. Maybe it's the difference in database of the procedure and the students table? Or a missing semi-colon?

CREATE PROCEDURE `cap-reports`.ffap_test(IN pName VARCHAR(10))
BEGIN
    select * FROM `cap-reports`.members m WHERE m.Username = pName;
END
;

CALL `cap-reports`.ffap_test('winkbrace');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM