Re: Update Trigger in IDS 7.3
Posted in 1998
Hi !! Madan..
Values are not inserted in table tab2 b'cause condition
WHEN(pre.col2 != post.col2) can not be evaluated if one of the opeands in
the condition is NULL, this is b;cause u can't use = ,!= operator for
comarision of NULL values instead u should use
IS NULL and IS NOT NULL operators for NULL values.
in your trigger u can use when condition as :
WHEN( (pre.col2 ! = post.col2) OR
(pre.col2 IS NOT NULL and post.col2 IS NULL) OR
(pre.col2 IS NULL and post.col2 IS NOT NULL))
(INSERT INTO tab2 (..,..) values (..,..));
Have Fun...
Sunil
On Thu, 17 Sep 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
> for each row when (pre.col2 != post.col2)
> (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
>
>
>
>