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

Error in executing factorial part of listing 5-3 #35

Open
aman-313 opened this issue Dec 22, 2021 · 1 comment
Open

Error in executing factorial part of listing 5-3 #35

aman-313 opened this issue Dec 22, 2021 · 1 comment
Assignees

Comments

@aman-313
Copy link

Having trouble with data, code, or exercises in Practical SQL? I'm glad to help. Please answer these questions, and I'll typically reply within one to two business days.

Please include the chapter number in your issue title. For example: "Chapter 13: Regular Expression Question"

General

Please answer all of these as they're essential for troubleshooting.

What's your operating system (e.g. Windows 10, macOS Catalina, Ubuntu, etc.)?
Windows 10

Did you install PostgreSQL and pgAdmin according to the steps on page xxviii of the book's Introduction? If not, please describe your installation.
Yes

Which versions of PostgreSQL and pgAdmin 4 are you using? If you aren't sure, for PostgreSQL run the SQL command SELECT version(); and for pgAdmin 4, navigate to "About pgAdmin 4" under the "Help" menu.
PostgreSQL = 14
pgAdmin 4 = 6.1

Did you download the book's code examples and data from GitHub using the directions on page xxvii of the Introduction? If not, please describe how you loaded the material on your computer.

Issue or Question

Chapter, page and code listing number:
Chapter 5, listing 5-3

Describe the issue or your question:
Code mentioned in book for calculating factorial of a number is not executing successfully. It is showing an error at the end of the syntax. However, for this I am able to use inbulit factorial function. SELECT FACTORIAL(4);

Please paste the code and error message here. It's OK to alter identifying info such as a folder name
SELECT 4 !; -- factorial
D

ERROR: syntax error at or near ";"
LINE 1: SELECT 4 !; -- factorial
^
SQL state: 42601
Character: 11

@anthonydb
Copy link
Owner

Thanks for noting this, @aman-313!

Beginning with PostgreSQL 14, released in September 2021, the factorial operator (!) has been deprecated. Instead, we must use the factorial() function.

I have made a note in the FAQ and updated Listing 5-3 with a note and the function.

The factorial operator has been removed in the upcoming 2nd Edition of the book as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants