In order to mimic a switch statement, put the switch value directly after "CASE" before the "WHEN". Every when statement will check to see if it's value equals the CASE value.
Example using the specialized case statement to return hex color values for color words:
DO $$
DECLARE
test_color varchar;
hex_color varchar;
BEGIN
test_color := 'blue';
hex_color :=
CASE test_color
WHEN 'red' THEN
'#FF0000'
WHEN 'blue' THEN
'#0000FF'
WHEN 'yellow' THEN
'#FFFF00'
ELSE --we do not use that color, replace with white
'#FFFFFF'
END;
END $$
I'm not able to test the anonymous block on my computer so here's a straight SQL statement I've tested to work which can be used in an anonymous block:
SELECT
CASE 'blue'
WHEN 'red' THEN
'#FF0000'
WHEN 'blue' THEN
'#0000FF'
WHEN 'yellow' THEN
'#FFFF00'
ELSE --we do not use that color, replace with white
'#FFFFFF'
END;