Bird
0
0

Identify the error in the following procedure:

medium📝 Debug Q6 of 15
SQL - Stored Procedures and Functions
Identify the error in the following procedure:
CREATE PROCEDURE AddNumbers(IN a INT, IN b INT)
BEGIN
  SET sum = a + b;
END;
AMissing parentheses after procedure name
BIncorrect keyword 'IN' for parameters
CVariable 'sum' is not declared before use
DMissing semicolon after BEGIN
Step-by-Step Solution
Solution:
  1. Step 1: Check variable usage inside procedure

    The variable 'sum' is used without declaration or definition inside the procedure.
  2. Step 2: Understand variable declaration rules

    Local variables must be declared with DECLARE before use inside BEGIN-END block.
  3. Final Answer:

    Variable 'sum' is not declared before use -> Option C
  4. Quick Check:

    Declare variables before SET inside procedures [OK]
Quick Trick: Declare variables before using SET inside procedures [OK]
Common Mistakes:
  • Using variables without DECLARE
  • Confusing parameter and local variable usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes