Skip site navigation (1) Skip section navigation (2)

Re: print statements?

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: print statements?
Date: 2006-12-19 16:37:45
Message-ID: 20061219163745.GA9616@KanotixBox (view raw or flat)
Thread:
Lists: pgsql-novice
tlm <tlm1905(at)gmail(dot)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°

In response to

pgsql-novice by date

Next:From: Chandra Sekhar SurapaneniDate: 2006-12-19 18:54:30
Subject: Re: Getting a count from an update
Previous:From: Brandon AikenDate: 2006-12-19 16:27:03
Subject: Re: print statements?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group