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

时间:2017-04-01 21:16:55

标签: mysql rowcount

执行Insert into语句后,ROW_COUNT()始终返回-1。但是当我设置variable = ROW_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;

0 个答案:

没有答案