Separating raise notice lines
I like to use RAISE NOTICE statements to make sure my functions are working correctly. I just wrote a trigger function that has the following code:
-- We have a new tender. Find out who it is.
select into userRecord * from users where users_key = new.tender_key;
if not found then
raise exception 'Could not store furnace tender information; no user has a key of %', new.tender_key;
else
raise notice 'User name is % %', userRecord.name, chr(10);
end if;
-- Now we can store the information.
insert into furnace_tender_history (area, tender_name, tender_checknum, signin_time, signin_time_utc)
values (new.area, userRecord.name, userRecord.check_number, current_timestamp, current_timestamp at time zone 'utc');
raise notice 'History record should be added%', chr(10)::text;
return new;
I am trying to insert a carriage return character (chr(10)) in the user name notice so that any subsequent notices will appear on separate lines. However, when I use a query to update a field that will fire this trigger, the Messages tab contains this:
NOTICE: User name is capsNOTICE: History record should be added
Query returned successfully: 1 rows affected, 16 ms execution time.
How can I get the notices to appear on separate lines?
Thanks very much!
RobR
Radcon Entec wrote:
I like to use RAISE NOTICE statements to make sure my functions are working correctly. I just wrote a trigger function that has the following code:
[snip]
I am trying to insert a carriage return character (chr(10)) in the user name notice so that any subsequent notices will appear on separate lines. However, when I use a query to update a field that will fire this trigger, the Messages tab contains this:
You're apparently not using psql. Normally, notices are printed
one-per-line by psql.
What is the "Messages" tab? in what software?
--
Craig Ringer
On Jun 23, 2009, at 10:27 PM, Radcon Entec wrote:
raise notice 'User name is % %', userRecord.name, chr(10);
I am trying to insert a carriage return character (chr(10)) in the
user name notice so that any subsequent notices will appear on
separate lines. However, when I use a query to update a field that
will fire this trigger, the Messages tab contains this:NOTICE: User name is capsNOTICE: History record should be added
As you're apparently using a Windows client you probably need to print
\r\n (characters 13 and 10) instead of just \n to make your client
understand the newline. The fault is in the client though, so maybe
you don't want to handle that on the server-side.
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.
!DSPAM:737,4a41e08a759153794312201!