Ala*_*laa 14 mysql sql stored-procedures
我在MySQL中存储过程,如下所示:
create procedure SP_Test (input1 varchar(20))
begin
update Table1 set Val1='Val' where country=input1;
//I want to see if this update changed how many rows and
//do some specific action based on this number
....
end
Run Code Online (Sandbox Code Playgroud)
如何确定此更新更改了多少行?
Joe*_*lli 23
使用ROW_COUNT():
SELECT ROW_COUNT();
Run Code Online (Sandbox Code Playgroud)
Ran*_*ndy -2
一种不太理想的方法是在更新之前简单地进行选择。
select count(*) from table1 where country = 'country1'
Run Code Online (Sandbox Code Playgroud)