gmocamilotd
1/17/2018 - 3:48 PM

How to RAISE a NOTICE in PostgreSQL?

RAISE NOTICE 'hello, world!'; And the server says:

Error : ERROR: syntax error at or near "RAISE" LINE 1: RAISE NOTICE 'hello, world!' ^

DO language plpgsql $$
BEGIN
  RAISE NOTICE 'hello, world!';
END
$$;


or-----------

RAISE NOTICE '%', variable_name;

-----------------------------
you can make a function apporpiate:

create or replace function r(error_message text) returns void as $$
begin
    raise notice '%', error_message;
end;
$$ language plpgsql;



usage:
select r('an error message');

~ NOTICE:  an error message


o---------------------------

DO $$ 
BEGIN 
RAISE INFO '% ',  md5('jose');
END $$;
INFO:  

o------------------------------


DO $$ 
declare q integer;
declare h varchar;
BEGIN 
q = 5;
q = q +5;
h = md5('jose');
RAISE INFO '% ', h ;
 RAISE NOTICE 'hello, world!';
 raise info '%', q;
END $$;