Description
Chapter 17: Saving Time with Views, Functions, and Triggers - Listing 17-15
Operating System: Windows 10
Did you install PostgreSQL, PostGIS and pgAdmin according to the steps in Chapter 1?
- Yes
Which versions of PostgreSQL and pgAdmin 4 are you using? - PostgreSQL 16
- pgAdmin 4 - Version 8.10
Did you download the book's code examples and data from GitHub using the directions in Chapter 1? - Yes
Chapter, page and code listing number:
Chapter 17: Saving Time with Views, Functions, and Triggers, pages 351-352, Listing 17-15
Describe the issue or your question:
Unable to resolve error (see below). I did some internet searching, but couldn't find any suggestions to resolve this on my own.
Please paste the code and error message here. It's OK to alter identifying info such as a folder name
ERROR: unterminated dollar-quoted string at or near "$$
BEGIN
UPDATE teachers
SET personal_days =
CASE WHEN (now() - hire_date) >= '10 years'::interval
AND (now() - hire_date) < '15 years'::interval THEN 4
WHEN (now() - hire_date) >= '15 years'::interval
AND (now() - hire_date) < '20 years'::interval THEN 5
WHEN (now() - hire_date) >= '20 years'::interval
AND (now() - hire_date) < '25 years'::interval THEN 6
WHEN (now() - hire_date) >= '25 years'::interval THEN 7
ELSE 3
END;"
LINE 2: AS $$
^
SQL state: 42601
Character: 55