Challenge - 5 Problems
RAISE Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this RAISE NOTICE statement?
Consider the following PostgreSQL code snippet:
What will be the output when this code runs?
DO $$ BEGIN RAISE NOTICE 'Hello, %!', 'world'; END $$;
What will be the output when this code runs?
PostgreSQL
DO $$ BEGIN RAISE NOTICE 'Hello, %!', 'world'; END $$;
Attempts:
2 left
💡 Hint
RAISE NOTICE is used to send informational messages without stopping execution.
✗ Incorrect
The RAISE NOTICE command outputs an informational message to the client. It does not stop the transaction or raise an error.
❓ query_result
intermediate2:00remaining
What error does this RAISE EXCEPTION produce?
Examine this PostgreSQL code:
What happens when this code runs?
DO $$ BEGIN RAISE EXCEPTION 'Invalid input: %', 42; END $$;
What happens when this code runs?
PostgreSQL
DO $$ BEGIN RAISE EXCEPTION 'Invalid input: %', 42; END $$;
Attempts:
2 left
💡 Hint
RAISE EXCEPTION stops execution and raises an error.
✗ Incorrect
RAISE EXCEPTION raises an error with the given message and aborts the current transaction or block.
📝 Syntax
advanced2:00remaining
Which option causes a syntax error in RAISE statement?
Identify which RAISE statement is syntactically incorrect in PostgreSQL:
Attempts:
2 left
💡 Hint
Check the placement of commas and parameters in RAISE syntax.
✗ Incorrect
Option A is missing a comma between the format string and the parameter, causing a syntax error.
🧠 Conceptual
advanced2:00remaining
What is the effect of RAISE EXCEPTION inside a transaction block?
If a RAISE EXCEPTION is executed inside a transaction block in PostgreSQL, what happens?
Attempts:
2 left
💡 Hint
Think about how exceptions affect transactions in databases.
✗ Incorrect
RAISE EXCEPTION aborts the current transaction and rolls back all changes made in it.
🔧 Debug
expert3:00remaining
Why does this RAISE NOTICE not display the variable value?
Given this PostgreSQL code:
Why does it not show the value of 'val' in the notice?
DO $$ DECLARE val integer := 10; BEGIN RAISE NOTICE 'Value is %'; END $$;
Why does it not show the value of 'val' in the notice?
PostgreSQL
DO $$ DECLARE val integer := 10; BEGIN RAISE NOTICE 'Value is %'; END $$;
Attempts:
2 left
💡 Hint
Check how placeholders and variables are used in RAISE statements.
✗ Incorrect
The placeholder '%' requires a corresponding argument after the format string to display the variable value.