How to run an ad-hoc script in PostgreSQL?

后端 未结 3 1767
攒了一身酷
攒了一身酷 2020-12-24 05:20

I\'m trying to run this in PostgreSQL 9.2:

RAISE NOTICE \'hello, world!\';

And the server says:

Error : ERROR:  syntax erro         


        
3条回答
  •  一整个雨季
    2020-12-24 06:17

    raise is PL/pgSQL only.

    http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

    create or replace function r(error_message text) returns void as $$
    begin
        raise notice '%', error_message;
    end;
    $$ language plpgsql;
    
    select r('an error message');
    NOTICE:  an error message
    

提交回复
热议问题