Thread: echo/printf function in plpgsql
Hi all! Is there a way of echo'ing a string(like "raise notice 'this is id%', id") from plpgsql? I want to echo/print it to STDOUT 'cause the notice-mechanism produces too much noise IMH. -- Andreas
Andreas Joseph Krogh wrote: > Hi all! > > Is there a way of echo'ing a string(like "raise notice 'this is id%', id") > from plpgsql? I want to echo/print it to STDOUT 'cause the notice-mechanism > produces too much noise IMH. Your function is running in the backend. You don't have a STDOUT (although you might have redirected STDERR for logging). -- Richard Huxton Archonet Ltd
On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > Andreas Joseph Krogh wrote: > > Hi all! > > > > Is there a way of echo'ing a string(like "raise notice 'this is id%', > > id") from plpgsql? I want to echo/print it to STDOUT 'cause the > > notice-mechanism produces too much noise IMH. > > Your function is running in the backend. You don't have a STDOUT > (although you might have redirected STDERR for logging). I see. Can I make the ouput somehow less verbose? It spits out a lot of noise for each "NOTICE": ==================== psql:ocs_process_projecct.sql:48: NOTICE: trying to insert parent_id: 87, child_id: 91 CONTEXT: SQL statement "SELECT processSubProject( $1 , $2 , $3 )" PL/pgSQL function "processsubproject" line 7 at perform SQL statement "SELECT processSubProject( $1 , $2 , $3 )" PL/pgSQL function "processsubproject" line 7 at perform SQL statement "SELECT processSubProject( $1 , $2 , $3 )" PL/pgSQL function "build_project_children" line 11 at perform ==================== -- AJk
On 7/19/05, Andreas Joseph Krogh <andreak@officenet.no> wrote: > On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > > Andreas Joseph Krogh wrote: > > > Hi all! > > > > > > Is there a way of echo'ing a string(like "raise notice 'this is id%', > > > id") from plpgsql? I want to echo/print it to STDOUT 'cause the > > > notice-mechanism produces too much noise IMH. > > > > Your function is running in the backend. You don't have a STDOUT > > (although you might have redirected STDERR for logging). > > I see. Can I make the ouput somehow less verbose? It spits out a lot of noise > for each "NOTICE": You can control the severity messages sent to your client by first setting client_min_message. Try SET client_min_messages = WARNING; http://www.postgresql.org/docs/8.0/interactive/runtime-config.html Tony
On Tuesday 19 July 2005 22:09, Tony Wasson wrote: > On 7/19/05, Andreas Joseph Krogh <andreak@officenet.no> wrote: > > On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > > > Andreas Joseph Krogh wrote: > > > > Hi all! > > > > > > > > Is there a way of echo'ing a string(like "raise notice 'this is id%', > > > > id") from plpgsql? I want to echo/print it to STDOUT 'cause the > > > > notice-mechanism produces too much noise IMH. > > > > > > Your function is running in the backend. You don't have a STDOUT > > > (although you might have redirected STDERR for logging). > > > > I see. Can I make the ouput somehow less verbose? It spits out a lot of > > noise for each "NOTICE": > > You can control the severity messages sent to your client by first > setting client_min_message. > > Try SET client_min_messages = WARNING; Thanks -- AJK
On Jul 19, 2005, at 11:58 AM, Andreas Joseph Krogh wrote: > I see. Can I make the ouput somehow less verbose? It spits out a > lot of noise > for each "NOTICE": If you just want to output some information to the log, you can use something like this: raise log 't is %', t; If I recall correctly, the values to be inserted into the format string can only be variables, not expressions. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL
On Wednesday 20 July 2005 01:39, John DeSoi wrote: > On Jul 19, 2005, at 11:58 AM, Andreas Joseph Krogh wrote: > > I see. Can I make the ouput somehow less verbose? It spits out a > > lot of noise > > for each "NOTICE": > > If you just want to output some information to the log, you can use > something like this: > > raise log 't is %', t; > > If I recall correctly, the values to be inserted into the format > string can only be variables, not expressions. Thanks! -- AJK