Re: Update Trigger in IDS 7.3
Posted in 1998
Madan Mashalkar wrote:
>
> Hi,
>
> Environment : IDS 7.30UC3 , Sun Solaris
> This is a question about update triggers.
>
> There is a simple trigger:
> create trigger upd_tab1 update of col2 on tab1
> referencing old as pre new as post>
> (insert into tab2 (col1,col2) values ('GOT' ,'IT!' ));
>
> Then inserting and updating a row in an empty table tab1:
>
> insert into tab1 (col1,col2) values('TEST',null);
> update tab1 set col2 = 'NEW' where col1 = 'TEST';>
> No rows are inserted in tab2.
> (Interesting, if either the pre or the post value is NULL,
> no rows are inserted in tab2)
>
> The manual states that if the 'when' evaluates to false/unknown, then
> the action(insert) will not be done.
>
> So, does (pre.col2 != post.col2) evaluate to unknown ???
> If yes, then is it expected behaviour ?
>
> Confused , and awaiting clarifications...
>
> Thanks
> Madan
Hi,
never try to compare NULL values by equal (=) or not-equal (!=)
operators. Expand your condition to:
for each row when (pre.col2 != post.col2 or pre.col2 is null
or post.col2 is null )
Because (NULL = NULL) will be evaluated to FALSE.
Bye
Stefan Weideneder