'Syntax error in Postgres using if statement
Using the DBeaver tool to run PostgreSQL, and getting error SQL Error [42601]: ERROR: syntax error at or near "if"
query -
DO $$
if (1<2) then select 1
end if;
end $$;
Solution 1:[1]
https://www.postgresql.org/docs/current/errcodes-appendix.html
=>> 42601 syntax_error means syntax error.
Google search "postgresql do block" will link you to https://www.postgresql.org/docs/current/sql-do.html
By imitate manual example. You can rewrite the following way.
DO $$
begin
if (1<2) then raise info '1';
end if;
end $$;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mark |
