Skip to content
Advertisement

How to declare a variable holding select query result in a stored procedure?

I have a MySql stored procedure in which I have a variable which will hold the result of a select query.

But I am unable to use the variable, as I believe one must declare variables with their data types in a stored procedure.

This is a snippet of what I’m trying to do:

I’m getting a syntax error with isPartionPresent variable.

Advertisement

Answer

You’re mixing local variables with user defined variables. There’s a difference between the two.

Read more about the differences in the manual:

Just decide on which variable type you want to use. Your procedure should work with this for example:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement