RAISE NOTICE uses format string with % and variable as argument, as in RAISE NOTICE 'Current value: %', val; RAISE EXCEPTION USING MESSAGE = 'Custom error', SQLSTATE = 'P0001';.
Step 2: Verify RAISE EXCEPTION with SQLSTATE
Correct syntax uses RAISE EXCEPTION USING MESSAGE and SQLSTATE, as in RAISE NOTICE 'Current value: %', val; RAISE EXCEPTION USING MESSAGE = 'Custom error', SQLSTATE = 'P0001';.
Step 3: Identify syntax errors in other options
The other three options misuse concatenation, parentheses, or keywords.
Final Answer:
RAISE NOTICE 'Current value: %', val; RAISE EXCEPTION USING MESSAGE = 'Custom error', SQLSTATE = 'P0001'; -> Option D
Quick Check:
Use USING clause for custom SQLSTATE in RAISE EXCEPTION [OK]
Quick Trick:Use USING MESSAGE and SQLSTATE for custom exceptions [OK]
Common Mistakes:
Concatenating strings instead of using % placeholders
Incorrect syntax for SQLSTATE assignment
Omitting USING keyword
Master "PL/pgSQL Fundamentals" in PostgreSQL
9 interactive learning modes - each teaches the same concept differently