Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a variable named counter of type integer.
PostgreSQL
DECLARE counter [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT instead of INTEGER for numeric variables.
Forgetting the semicolon at the end.
✗ Incorrect
The INTEGER type is used to declare a variable that holds whole numbers.
2fill in blank
mediumComplete the code to assign the value 10 to the variable counter.
PostgreSQL
counter [1] 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Using == which is not valid in PostgreSQL.
✗ Incorrect
In PostgreSQL procedural language, := is used to assign values to variables.
3fill in blank
hardFix the error in the variable declaration to declare username as a text variable.
PostgreSQL
DECLARE username [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using INT for text variables.
Using BOOLEAN instead of a string type.
✗ Incorrect
The TEXT type is used for variable-length strings in PostgreSQL.
4fill in blank
hardFill both blanks to declare a variable total as integer and assign it the value 0.
PostgreSQL
DECLARE total [1]; BEGIN total [2] 0; END;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Declaring the variable as TEXT instead of INTEGER.
✗ Incorrect
Use INTEGER to declare the variable type and := to assign the value.
5fill in blank
hardFill all three blanks to declare a variable flag as boolean, assign it true, and then reassign it false.
PostgreSQL
DECLARE flag [1]; BEGIN flag [2] TRUE; flag [3] FALSE; END;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Declaring the variable as INTEGER instead of BOOLEAN.
✗ Incorrect
Declare flag as BOOLEAN. Use := to assign values in PL/pgSQL.