Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 17: Saving Time with Views, Functions, and Triggers - Listing 17-15 #30

Open
mkschihl opened this issue Oct 28, 2024 · 1 comment
Assignees
Labels
help wanted Extra attention is needed Solved

Comments

@mkschihl
Copy link

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

@mkschihl mkschihl added the help wanted Extra attention is needed label Oct 28, 2024
@anthonydb
Copy link
Owner

Hi, @mkschihl,

Thanks for reading my book!

In pgAdmin, please make sure you have highlighted the entire block of code for Listing 17-15 before running it. A recent change to pgAdmin lets a user just click anywhere into a block of code to run it. That works OK for most queries/statements, but in more complicated ones like this it doesn't work so well.

I just ran Listing 17-15 on a fresh database on Windows and it worked fine, so I suspect that is the issue you're having.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Solved
Projects
None yet
Development

No branches or pull requests

2 participants