Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 为什么ROW_COUNT()在插入值后总是返回-1?_Mysql_Rowcount - Fatal编程技术网

Mysql 为什么ROW_COUNT()在插入值后总是返回-1?

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

执行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); /** 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()的行为发生了变化。见:谢谢你的建议