即使更新更改了数据库,Mysql ROW_COUNT()也会返回零。我有一个存储过程A,它调用了另一个具有更新语句的存储过程B。我还使用了set AUTOCOMMIT = 0并在存储过程A中启动事务。
在步骤A
DECLARE done INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET done = 1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION,sqlwarning
BEGIN
GET CURRENT DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO, msg = MESSAGE_TEXT;
set Message = concat(errno , msg);
ROLLBACK;
END;
set autocommit = 0 ;
start transaction;
call test_update(@Inv_Header_gid,@Message1);
select @Message1 into @out_SOINV_Msg;
if @out_SOINV_Msg <> 'SUCCESS' then
set Message = concat('Error On SOInvoice Update ',@out_SOINV_Msg);
rollback;
leave sp_DispatchProcess_Set;
end if;
if @out_SOINV_Msg = 'SUCCESS' then
set Message = 'SUCCESS';
end if;
在过程B中
declare Query_Updatee varchar(1000);
declare update_countt int;
set INV_Header_Gid = '999';
set Query_Updatee= Concat('Update gal_mst_tdealerprice set dealerprice_status = ''no136jj''
where dealerprice_gid = ',INV_Header_Gid,'');
set @Query_Updatee = Query_Updatee;
PREPARE stmtr FROM @Query_Updatee;
EXECUTE stmtr;
set update_countt = (select ROW_COUNT());
select found_rows();
DEALLOCATE PREPARE stmtr;
if update_countt > 0 then
set Messagee = 'SUCCESS';
else
set Messagee ='FAILZrtttt';
select update_countt;
rollback;