I have the following in an sql file I am executing…
DECLARE rowcount INT;
SELECT COUNT(*) INTO rowcount
FROM VRG_PROBLEM_ACCOUNT PA
WHERE NEW.CustName = PA.CustNAME
AND NEW.AreaCode = PA.AreaCode
AND NEW.PhoneNumber = PA.PhoneNumber;
And yet I’m getting
ERROR 1327 (42000): Undeclared variable: rowcount
In another file I am doing the same type of SELECT…INTO localvariable and it works.
Local variables can only be declared inside of stored routines. You can use @-variables instead, which don’t need to be declared at all: