Re: Trigger problem

From: "Christian Rengstl" <Christian(dot)Rengstl(at)klinik(dot)uni-regensburg(dot)de>
To: <pgsql-general(at)postgresql(dot)org>, "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Subject: Re: Trigger problem
Date: 2007-11-27 10:10:57
Message-ID: 474BFB9E.90AD.0080.0@klinik.uni-regensburg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for pinpointing that out. After including your solution it shows
at least something like "UPDATE OF with id: 123456567". Unfortunately
after using coalesce, too, when building the field variable like: field
= 'field gruppe from: ' || coalesce(OLD.gruppe, '') || ' TO ' ||
coalesce(NEW.gruppe, ''); there still seem to be null values. Of course,
it can be that the user deletes a value and then there is a NULL value,
say for NEW.gruppe for example, but shouldn't the coalesce in this case
avoid that the whole field-string is empty?

Christian Rengstl M.A.
Klinik und Poliklinik für Innere Medizin II
Kardiologie - Forschung
Universitätsklinikum Regensburg
B3 1.388
Franz-Josef-Strauss-Allee 11
93053 Regensburg
Tel.: +49-941-944-7230

>>> On Tue, Nov 27, 2007 at 10:53 AM, in message
<20071127095336(dot)GF31593(at)a-kretschmer(dot)de>, "A. Kretschmer"
<andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> am Tue, dem 27.11.2007, um 10:38:09 +0100 mailte Christian Rengstl
> folgendes:
>> Hi list,
>>
>> act = 'DELETION of row with id: ' || OLD.id;
>> act = 'UPDATE OF ' || field || ' with id: ' ||
>> ...
>> INSERT INTO history(aennam, action, table_name)
VALUES(current_user,
>> act, tab);
>>
>> Now the problem is that a tuple gets added to the table history,
but
>> the field "action" (whatever the user did) is 99% empty, whereas
the
>> others are filled and I don't see why...
>>
>> Any hint is greatly appreciated
>
> Maybe sometime the concateneted fields (e.g. field, OLD.id) contains
> NULL- values. If so, the complete string 'act' will be NULL.
>
> Solution: use coalesce(field,''). Hope that helps.
>
>
> Andreas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wolfgang Keller 2007-11-27 10:11:22 Re: Linux v.s. Mac OS-X Performance
Previous Message A. Kretschmer 2007-11-27 09:53:36 Re: Trigger problem