
Problems using new v7.2 features (or, What's wrong with this syntax?)
Context: IBM DB2 v7.2 (i.e., FP3) running on WinNT 4.0.
I'm trying to make use of the new control statements (e.g., IF, FOR, LOOP,
etc.) now available in triggers. Unfortunately, I'm not having much luck,
and the 7.2 release notes seem to be pretty sparse (for example, there
is little documentation of the new IF statement, nor any example of it
in use).
For example, the following trigger generates the following error:
create trigger Users_A_Audit_I01
no cascade before insert on Users
referencing new as new
for each row mode db2sql
begin atomic
if (user <> 'MICA')
begin atomic
set new.created_by = user;
set new.created_on = current timestamp;
set new.updated_by = user;
set new.updated_on = current timestamp;
end
end
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "(user <> 'MICA' ) begin atomic set " was
found following "ql begin atomic if". Expected tokens may include:
"<name>". LINE NUMBER=8. SQLSTATE=42601
Clearly something is wrong with the IF statement, but what?
Thanks!
Doug Morse