Display Comments while Running Script

215 views Asked by At

I've seen the answer to this question in a couple posts. However when I the below which was an answer coming from another post, I get an error. My objective is to simply write comments to the screen as I execute DML commands in a script. However I have not found a simple way to do this.

CREATE OR REPLACE FUNCTION raise_exception(text)
RETURNS void AS $$
BEGIN
  RAISE EXCEPTION '%', $1;
END;
$$ LANGUAGE plpgsql;

Called like this: select * from sp_send_msg('go for it');

I would like to be able to do something like this:

SELECT send_comment('Writing widgets to temporary table');
SELECT * INTO t_widgets FROM widgets;

SELECT send_comment('Writing temporary table into new widget table');
INSERT INTO new_widgets
SELECT * FROM t_widgets;

Thanks in advance for any helpful guidance on this. I'm running PostgreSQL 8.4.7.

1

There are 1 answers

3
Tometzky On

You should raise notice instead of raise exception. The former will show a message and the latter is treated as an error and will abort your transaction.