Mysql 为什么ROW_COUNT()在插入值后总是返回-1?
执行Insert into语句后,Mysql 为什么ROW_COUNT()在插入值后总是返回-1?,mysql,rowcount,Mysql,Rowcount,执行Insert into语句后,ROW\u COUNT()始终返回-1。但是当我设置一个变量=ROW\u COUNT()时,该变量等于0。为什么? block0: BEGIN DECLARE contentid INT UNSIGNED; DECLARE remarkid INT UNSIGNED; **INSERT INTO richtext_base VALUES(NULL, "richtext", in_uid, in_content); /** Her
ROW\u COUNT()
始终返回-1
。但是当我设置一个变量=ROW\u COUNT()
时,该变量等于0
。为什么?
block0: BEGIN
DECLARE contentid INT UNSIGNED;
DECLARE remarkid INT UNSIGNED;
**INSERT INTO richtext_base
VALUES(NULL, "richtext", in_uid, in_content); /** Here is the insert into statement **/
IF (ROW_COUNT())=-1 THEN /** ROW_COUNT() always returns -1, so as those below**/**
SET out_eid = 152;
LEAVE block0;
ELSE
SET contentid = (SELECT LAST_INSERT_ID());
END IF;
END block0;
在MySQL 5.5中,row_count()的行为发生了变化。见:谢谢你的建议