【发布时间】:2015-06-15 18:37:29
【问题描述】:
我正在编写一个存储过程来将数据插入到 tbluser 表中。以下是我的存储过程:
BEGIN
/* Check if user already exits*/
DECLARE user_count INT;
select count(*) from tblusers into user_count where name = 'joseph';
/* Calculate the row count of table and calculate the id for new row*/
DECLARE totalrows,current_id INT;
select count(*) from tblusers into totalrows;
SET current_id = totalrows + 1;
/*Other part of procedure with insert statement*/
END
我收到错误名称 MYSQL 1064: 在 DECLARE totalrows,current_id INT 行;说 mysql 语法是错误的。如果我在存储过程中省略了前两个语句,那么它可以正常工作。请纠正我哪里错了,我是在 mysql 中使用存储过程的新手
【问题讨论】: