Printing run time messages in postgres Printing run time messages in postgres sql-server sql-server

Printing run time messages in postgres


Yes, you can use RAISE NOTICE like below. It's correct the way you are doing.

RAISE NOTICE 'i want to print % and %', var1,var2;

See here for more information https://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

EDIT:

beginINSERT INTO tbl1 (col1) values (val1);raise notice 'insert tbl1 done!';end;


you can use very simple statement in function everywhere.

DO $$ begin raise notice '%',now(); end; $$;

function for reference:

create or replace function test() RETURNS bool AS 'beginraise notice ''%'',now();for i IN 0..50000000  loop     end loop     raise notice ''%'',now();     return true;end;

LANGUAGE 'plpgsql';


RAISE NOTICE is part of PL/pgSQL so it's only legal in a function or an anonymous DO block. I guess you could make a function that raises the notice and call that.