Bird
0
0

You wrote this procedure to update a user's email:

medium📝 Debug Q14 of 15
SQL - Stored Procedures and Functions
You wrote this procedure to update a user's email:
CREATE PROCEDURE updateEmail(userId INT, newEmail VARCHAR(100)) BEGIN UPDATE users SET email = newEmail WHERE id = userId; END;

When you try to call it with SELECT updateEmail(1, 'test@example.com');, you get an error. What is the problem?
AProcedures cannot be called inside SELECT statements.
BThe procedure is missing a RETURN statement.
CThe UPDATE statement syntax is incorrect.
DThe procedure parameters must be declared as OUT.
Step-by-Step Solution
Solution:
  1. Step 1: Understand procedure usage

    Procedures perform actions but do not return values and cannot be called inside SELECT queries.
  2. Step 2: Identify error cause

    Calling a procedure with SELECT causes error because procedures are invoked with CALL, not SELECT.
  3. Final Answer:

    Procedures cannot be called inside SELECT statements. -> Option A
  4. Quick Check:

    Use CALL for procedures, not SELECT [OK]
Quick Trick: Call procedures with CALL, not SELECT [OK]
Common Mistakes:
  • Trying to use SELECT to call procedures
  • Expecting procedures to return values
  • Misunderstanding parameter directions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes