Bird
0
0

You want to create a stored procedure that accepts a product ID and returns the product name and price. Which approach best uses stored procedures to improve performance and security?

hard📝 Application Q8 of 15
SQL - Stored Procedures and Functions
You want to create a stored procedure that accepts a product ID and returns the product name and price. Which approach best uses stored procedures to improve performance and security?
ACreate a procedure that takes product ID as input and returns only name and price columns
BCreate a procedure that returns all columns from the products table
CCreate a procedure that accepts no parameters and returns all products
DCreate a procedure that updates product price without returning data
Step-by-Step Solution
Solution:
  1. Step 1: Identify input and output needs

    Procedure should accept product ID to filter and return only needed columns.
  2. Step 2: Evaluate options for performance and security

    Returning only required columns reduces data transfer and hides unnecessary info.
  3. Final Answer:

    Create a procedure that takes product ID as input and returns only name and price columns -> Option A
  4. Quick Check:

    Filter input and limit output for best practice [OK]
Quick Trick: Limit output columns and use parameters for security [OK]
Common Mistakes:
  • Returning all columns unnecessarily
  • Not using input parameters to filter data
  • Creating procedures that do unrelated updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes