Sample Header Ad - 728x90

PostgreSQL: Issue Declaring Variables in Query

0 votes
2 answers
8034 views
I'm trying to declare a variable for later use in a PostgreSQL query. I've done this often in TSQL, but I wasn't sure about the syntax. The stuff I've seen online all points to something like this: declare timestamp_utc timestamp := current_timestamp; select start_date; when I run the above query, I get an error message: ERROR: syntax error at or near I'm sure this is simple, but I just can't find the answer online. Any help you could provide would be greatly appreciated.
Asked by Lexen (13 rep)
Sep 8, 2023, 01:20 PM
Last activity: Sep 8, 2023, 02:16 PM