0
0
SQLquery~10 mins

Parameters (IN, OUT, INOUT) in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an input parameter named 'user_id' of type INT.

SQL
CREATE PROCEDURE GetUserName([1] INT) BEGIN SELECT name FROM users WHERE id = user_id; END;
Drag options to blanks, or click blank then click option'
AIN user_id
BOUT user_id
CINOUT user_id
DPARAM user_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUT or INOUT instead of IN for input parameters.
Forgetting to specify the parameter mode.
2fill in blank
medium

Complete the code to declare an output parameter named 'total_count' of type INT.

SQL
CREATE PROCEDURE CountUsers([1] INT) BEGIN SELECT COUNT(*) INTO total_count FROM users; END;
Drag options to blanks, or click blank then click option'
AVAR total_count
BOUT total_count
CINOUT total_count
DIN total_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN instead of OUT for output parameters.
Not using INTO clause to assign value to output parameter.
3fill in blank
hard

Fix the error in the procedure declaration by choosing the correct parameter mode for 'balance'.

SQL
CREATE PROCEDURE UpdateBalance(IN user_id INT, [1] balance DECIMAL(10,2)) BEGIN SET balance = balance + 100; END;
Drag options to blanks, or click blank then click option'
AINOUT
BOUT
CIN
DVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN when the parameter value needs to be changed inside the procedure.
Using OUT when the parameter needs an initial input value.
4fill in blank
hard

Fill both blanks to declare an INOUT parameter 'score' of type INT and assign it a new value inside the procedure.

SQL
CREATE PROCEDURE AdjustScore([1] score INT) BEGIN SET score [2] score + 10; END;
Drag options to blanks, or click blank then click option'
AINOUT
B=
C+=
DOUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUT instead of INOUT for parameters that need initial values.
Using += which is not valid in SQL for assignment.
5fill in blank
hard

Fill all three blanks to declare an OUT parameter 'result', assign it a value, and select it after procedure execution.

SQL
CREATE PROCEDURE CalculateSum(IN a INT, IN b INT, [1] result INT) BEGIN SET result [2] a + b; END; CALL CalculateSum(5, 10, @sum); SELECT [3];
Drag options to blanks, or click blank then click option'
AOUT
B=
C@sum
DINOUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN or INOUT instead of OUT for output parameters.
Forgetting to use session variables to get output values after CALL.