Bird
0
0

Given this procedure:

medium📝 query result Q5 of 15
SQL - Stored Procedures and Functions
Given this procedure:
CREATE PROCEDURE updateStock(productId INT, qty INT) AS $$ BEGIN UPDATE products SET stock = stock + qty WHERE id = productId; END; $$ LANGUAGE plpgsql;

What happens when you run CALL updateStock(5, 10);?
AThe procedure returns the new stock value
BAn error occurs because procedures cannot update tables
CThe stock of product with id 5 increases by 10
DNothing happens because procedures cannot be called
Step-by-Step Solution
Solution:
  1. Step 1: Understand procedure purpose

    The procedure updates the stock column by adding qty for the given productId.
  2. Step 2: Analyze the CALL statement

    CALL executes the procedure, increasing stock of product 5 by 10.
  3. Final Answer:

    The stock of product with id 5 increases by 10 -> Option C
  4. Quick Check:

    Procedure updates data, no return value [OK]
Quick Trick: Procedures perform actions, no direct return value [OK]
Common Mistakes:
  • Expecting procedure to return a value
  • Thinking procedures cannot update tables
  • Confusing CALL with SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes