0
0
MySQLquery~10 mins

Procedure parameters (IN, OUT, INOUT) in MySQL - 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 in a MySQL stored procedure.

MySQL
CREATE PROCEDURE AddNumbers([1] num1 INT, num2 INT)
BEGIN
  SELECT num1 + num2 AS sum_result;
END;
Drag options to blanks, or click blank then click option'
AVAR
BOUT
CINOUT
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUT or INOUT instead of IN for input parameters.
Omitting the parameter mode keyword.
2fill in blank
medium

Complete the code to declare an output parameter in a MySQL stored procedure.

MySQL
CREATE PROCEDURE GetCount([1] totalCount INT)
BEGIN
  SELECT COUNT(*) INTO totalCount FROM users;
END;
Drag options to blanks, or click blank then click option'
AIN
BINOUT
COUT
DVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN instead of OUT for output parameters.
Trying to assign values to IN parameters inside the procedure.
3fill in blank
hard

Fix the error in the procedure parameter declaration to allow both input and output.

MySQL
CREATE PROCEDURE UpdateScore(playerId INT, [1] score INT)
BEGIN
  SET score = score + 10;
END;
Drag options to blanks, or click blank then click option'
AINOUT
BOUT
CIN
DVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN or OUT alone when both input and output are needed.
Trying to modify an IN parameter inside the procedure.
4fill in blank
hard

Fill both blanks to declare an IN parameter and an OUT parameter in a procedure.

MySQL
CREATE PROCEDURE CalculateTax([1] amount DECIMAL(10,2), [2] tax DECIMAL(10,2))
BEGIN
  SET tax = amount * 0.15;
END;
Drag options to blanks, or click blank then click option'
AIN
BOUT
CINOUT
DVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUT for the first parameter or IN for the second parameter.
Omitting parameter modes.
5fill in blank
hard

Fill all three blanks to declare an IN parameter, an OUT parameter, and an INOUT parameter in a procedure.

MySQL
CREATE PROCEDURE AdjustValues([1] inputVal INT, [2] outputVal INT, [3] inoutVal INT)
BEGIN
  SET outputVal = inputVal * 2;
  SET inoutVal = inoutVal + 5;
END;
Drag options to blanks, or click blank then click option'
AIN
BOUT
CINOUT
DVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameter modes or omitting them.
Trying to modify IN parameters inside the procedure.