All Things Techie With Huge, Unstructured, Intuitive Leaps

MySQL ROW_COUNT() Bug?


Had a strange bug with a MySQL stored procedure.  Consider the following line:

START TRANSACTION;
Insert into conversations(subjectLine) values(subjectLine);
IF (ROW_COUNT() > 0) then
set @pass1 = 1;
end if;

 Look closely at the IF statement.  It works perfectly on a Windows server.  When you put the CREATE statement on a Linux machine in the mysql command line, it fails and fills with garbage.  

The fix took some head-scratching, but here it is:

START TRANSACTION;
Insert into conversations(subjectLine) values(subjectLine);
IF ((SELECT ROW_COUNT()) > 0) then
set @pass1 = 1;
end if;

I had to put (SELECT ROW_COUNT()) to make it work in the Linux command line.

No comments:

Post a Comment