Specifying tables and columns in conditional procedure

Am trying to do a conditional procedure. May have multiple errors in it as am not sure, but one thing at a time. Need to go through an entire table and update one columm, ELINENO, where the conditions in the IF column are true and when they evaluate as false, start the sequence again when the conditions become true again. The lno resets when evaluates false. @cnt is a session variable set to SELECT COUNT(*) for the whole table to step through all rows. i is a counter for number of times through the loop.


SET @cnt=(SELECT COUNT(*) FROM t1);
USE udb_b;
DROP PROCEDURE IF EXISTS lineno;
DELIMITER |
CREATE PROCEDURE lineno()
BEGIN
	DECLARE i INT DEFAULT 0;
	DECLARE lno INT DEFAULT 1;
	WHILE i<=@cnt DO
		BEGIN 
		SET i = i + 1;
			IF INVNO=INVNOZa AND PICKNO=PICKNOa AND DATEXP=DATEXPa
				THEN UPDATE elineno_2 SET ELINENO=ELINENO+lno;
				SET lno=lno+1;
				ELSE SET lno=1;
			END if;
		END;
	END WHILE;
END |
DELIMITER ;
CALL lineno();

The issue for the moment is that the procedure is giving me the error that the columns are unknown.

Error Code: 1054. Unknown column ‘INVNO’ in ‘field list’
. When the table was added in “.” notation, ie t1.INVNO, then the error was Unknown table. How do you get a procedure to reference a specific table/fields in a data base?

Also, for someone who knows what they are doing, it may be very obvious that more than that is wrong. Any help would be appreciated.

Thanks