1.通过以下SQL可以获取对应的select,与update delete insert返回的行数:
FOUND_ROWS() : select
ROW_COUNT() : update delete insert
简单示例:
DROP TABLE IF EXISTS Tbl_MarketLimit;
CREATE TABLE Tbl_MarketLimit (
ID int (11) not null AUTO_INCREMENT,
ItemID int(11) NOT NULL,
LimitCount int(11) not null,
IsValidate int(2) not null default 1,
PRIMARY KEY (`ID`),
KEY ItemID_index (ItemID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP PROCEDURE IF EXISTS Sp_MarketLimit;
DELIMITER ;;
CREATE PROCEDURE Sp_MarketLimit(
inItemID int(11),
inLimitCount int(11)
)
BEGIN
set @IsSucc = 0;
update Tbl_MarketLimit set LimitCount=inLimitCount where ItemID=inItemID and IsValidate=1;
select ROW_COUNT() into @IsSucc;
if @IsSucc = 0 then
insert into Tbl_MarketLimit(ItemID,LimitCount) values(inItemID,inLimitCount);
end if;
END;;