我在 MYSQL 中创建了以下 SP
CREATE PROCEDURE usp_BookDetailsCount(OUT bookCount INT)
BEGIN
SELECT count(*) INTO bookCount
FROM books;
SELECT bookCount;
END $$
我正在尝试使用 rails 3.2.8 获取 SP 输出参数值。
我在模型中的代码
count = 0
r = ActiveRecord::Base.connection.select_value("CALL usp_BookDetailsCount(OUT count)")
return count
我在浏览器中收到以下错误
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OUT count)' at line 1: CALL usp_BookDetailsCount(OUT count)
但是我可以在没有 OUT 参数的情况下获取存储过程值