Skip to content
Advertisement

Stored procedure with if statement not working

I want to create a stored procedure to check if the product has enough quantity in the purchase_info table.

This is my code. But it is not working, the result doesn’t show me the if…else query.

Can anyone help me fix it? Thank you.

Advertisement

Answer

There is a conflict between singular value of the @quantity parameter and multiple rows from the SELECT statement. So it prevents the comparison between them.

Please try to change the if clause logic as follows:

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