MySQL Forums
Forum List  »  Quality Assurance

row_count return value confuse ?
Posted by: Long Hoang Hai
Date: January 18, 2012 08:55PM

I have 2 stored procedure
sp_test1:
CREATE PROCEDURE sp_test1(
IN p_id INT
)
BEGIN
SET @stmt = "update Product set name = 'abc' where id=? limit 1";
prepare v_stmt from @stmt;
set @id = p_id;
execute v_stmt using @id;
deallocate prepare v_stmt;
select row_count();
END
call sp_test1(10);
=> row_count return 0
I think 0 mean the row affect by command previous "deallocate prepare v_stmt";

sp_test2:
CREATE PROCEDURE sp_test2(
IN p_id INT
)
BEGIN
SET @stmt = "update Product set name = 'abc' where id=? limit 1";
prepare v_stmt from @stmt;
set @id = p_id;
execute v_stmt using @id;
select row_count();
deallocate prepare v_stmt;
END
call sp_test1(10);
=> row_count return 1 if the name field is real changed.
I think 1 mean the row affect by command "execute v_stmt using @id";

So is that right ?
I was confused because my friend told me that in sp_test1, the row_count = 0 because we have execute an update statement before, even we call deallocate the statement.

Options: ReplyQuote


Subject
Views
Written By
Posted
row_count return value confuse ?
1466
January 18, 2012 08:55PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.