CREATE DEFINER=`root`@`localhost` PROCEDURE `add_item`(
IN parentId BIGINT UNSIGNED, IN jobId BIGINT UNSIGNED,
OUT id BIGINT UNSIGNED)
BEGIN
DECLARE newLeft INT UNSIGNED DEFAULT 0;
SELECT `RGT` into newLeft from `headings` where `ID`=parentId LIMIT 1;
/* ERROR TRAP */
IF (newLeft=0) OR (newLeft=NULL) THEN SET newLeft=1;
END IF;
Problem is I can't select the result into the local variable newLeft, it always equals 1 (or 0 if I remove the error trap). Am I missing something? I have tried so many different approaches, even putting the "INTO newLeft" at the end of the SELECT statement.
Using MYSQL 5.4 on test machine which is Windows 7 using IIs