Re: print statements? - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: print statements?
Date
Msg-id 20061219163745.GA9616@KanotixBox
Whole thread Raw
In response to print statements?  (tlm <tlm1905@gmail.com>)
List pgsql-novice
tlm <tlm1905@gmail.com> schrieb:

> [ 2nd try ]
>
> Hi.  I have an automated script that essentially feeds a long sequence of  SQL
> statements to psql, as a single transaction.  For debugging purposes, I would
> like to insert the equivalent of print statements (to write messages to stdout,
> stderr, or maybe some pre-specified log file) at various points in this
> sequence.  How is this done?

One solution: write a little function to write out there parameter via
RAISE NOTICE and call this function on the desired places.

I mean something tike this:

test=# create function write_out(text) returns void as $$ begin raise notice '%',$1; end; $$ language plpgsql immutable
strict;
CREATE FUNCTION
test=#
test=# select write_out('hint');
NOTICE:  hint
 write_out
-----------

(1 row)


and set 'log_min_messages = notice', then can you find your messages in
the log-file.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-novice by date:

Previous
From: "Brandon Aiken"
Date:
Subject: Re: print statements?
Next
From: "Chandra Sekhar Surapaneni"
Date:
Subject: Re: Getting a count from an update