0
0
MySQLquery~10 mins

Creating stored functions in MySQL - Interactive Practice

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

Complete the code to start creating a stored function named 'getSquare'.

MySQL
CREATE FUNCTION getSquare(num INT) RETURNS INT [1]
Drag options to blanks, or click blank then click option'
AAS
BBEGIN
CDECLARE
DEND
Attempts:
3 left
💡 Hint
Common Mistakes
Using AS instead of BEGIN to start the function body.
Forgetting to start the function body with BEGIN.
2fill in blank
medium

Complete the code to return the square of the input number inside the function.

MySQL
RETURN [1] * num; END
Drag options to blanks, or click blank then click option'
Anum - 1
Bnum + 1
Cnum
Dnum / 2
Attempts:
3 left
💡 Hint
Common Mistakes
Returning num + 1 instead of num * num.
Using division or subtraction instead of multiplication.
3fill in blank
hard

Fix the error in the function declaration by completing the missing keyword.

MySQL
CREATE FUNCTION getDouble(num INT) RETURNS INT [1] RETURN num * 2; END
Drag options to blanks, or click blank then click option'
AFUNCTION
BAS
CDECLARE
DBEGIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using AS instead of BEGIN to start the function body.
Omitting the BEGIN keyword entirely.
4fill in blank
hard

Fill both blanks to declare a variable and set it to the square of the input number.

MySQL
DECLARE result INT; SET result = num [1] num; RETURN [2]; END
Drag options to blanks, or click blank then click option'
A*
Bresult
C+
Dnum
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * for multiplication.
Returning num instead of the result variable.
5fill in blank
hard

Fill all three blanks to create a function that returns the cube of a number.

MySQL
CREATE FUNCTION getCube(num INT) RETURNS INT [1] DECLARE result INT; SET result = num [2] num [3] num; RETURN result; END
Drag options to blanks, or click blank then click option'
ABEGIN
B*
DAS
Attempts:
3 left
💡 Hint
Common Mistakes
Using AS instead of BEGIN to start the function.
Using + or other operators instead of * for multiplication.