Search code examples
postgresqlpgadmin-4

PgAdmin won't allow RAISE NOTICE


When I try to use RAISE NOTICE in a Query tool in PgAdmin I just get "ERROR: syntax error at or near "RAISE"". This is stopping defining a stored procedure which uses RAISE NOTICE.

I have simply typed the following into a Query Tool window:

RAISE NOTICE 'Bob';

I am using PgAdmin 6.3 (the latest), just updated from v4.5 which had the same problem.


Solution

  • RAISE is part of pl/pgsql, Postgres's default procedural language. It is not available in a direct SQL context, or any function or stored procedure defined with LANGUAGE sql rather than LANGUAGE plpgsql.

    If you're used to a different DBMS like MySQL or SQL Server, you might expect to have procedural code (variables, conditionals, loops, etc) available by default, but that's not how Postgres works. In order to use procedural code, you need to be inside a function, stored procedure, or DO statement.