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;
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;
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.
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