错误码: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 贴完整定义返回变量rowCount select ROW_COUNT() into rowCount return rowCount
DELIMITER $$:前面有无空格 用ROW_COUNT()返回行数
这段语句是在什么工具中执行的? 请在MYSQL自带的命令行工具中进行测试。
USE `xiehou_3`; DROP PROCEDURE IF EXISTS `proc`; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `proc`(IN iuid INT,IN icnt INT) BEGIN DECLARE idate DATE; SELECT `date` INTO idate FROM tb_act20140602_user_value WHERE uid=iuid; IF idate IS NULL THEN INSERT INTO tb_act20140602_user_value VALUES(iuid,icnt,NOW(),icnt,icnt,NOW()); ELSEIF idate=CONVERT(NOW(),DATE) THEN UPDATE tb_act20140602_user_value SET daycnt=daycnt+icnt,maxcnt=maxcnt+icnt,`count`=`count`+icnt,lastModifyTime=NOW() WHERE uid=iuid; ELSE UPDATE tb_act20140602_user_value SET daycnt=icnt,maxcnt=maxcnt+icnt,`count`=`count`+icnt,lastModifyTime=NOW(),`date`=NOW() WHERE uid=iuid; END IF; END $$
错误码: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 贴完整定义返回变量rowCount
select ROW_COUNT() into rowCount
return rowCount
用ROW_COUNT()返回行数
USE `xiehou_3`;
DROP PROCEDURE IF EXISTS `proc`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc`(IN iuid INT,IN icnt INT)
BEGIN
DECLARE idate DATE;
SELECT `date` INTO idate FROM tb_act20140602_user_value WHERE uid=iuid;
IF idate IS NULL THEN
INSERT INTO tb_act20140602_user_value VALUES(iuid,icnt,NOW(),icnt,icnt,NOW());
ELSEIF idate=CONVERT(NOW(),DATE) THEN
UPDATE tb_act20140602_user_value SET daycnt=daycnt+icnt,maxcnt=maxcnt+icnt,`count`=`count`+icnt,lastModifyTime=NOW() WHERE uid=iuid;
ELSE
UPDATE tb_act20140602_user_value SET daycnt=icnt,maxcnt=maxcnt+icnt,`count`=`count`+icnt,lastModifyTime=NOW(),`date`=NOW() WHERE uid=iuid;
END IF;
END
$$
最后一行DELIMITER ; 中间没空格嗯,加上空格就对了,在问下怎么在resultset中获取受影响的行数呢??
select ROW_COUNT() into @aa 存入变量