Open aman-313 opened 2 years ago
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.
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.1Did 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
ERROR: syntax error at or near ";" LINE 1: SELECT 4 !; -- factorial ^ SQL state: 42601 Character: 11