I am getting the message:
[IBM][CLI Driver][DB2/LINUX] SQL0407N Assignment of a NULL value to a
NOT NULL column "TBSPACEID=2, TABLEID=113, COLNO=1" is not allowed.
SQLSTATE=23502
while running the statement:
MERGE INTO is2.ent_herdid t1
USING is2.animals t2
ON t2.bhid = t1.bhid
OR t2.assoc <> 'AN'
OR t2.tattoo IS NULL
WHEN NOT MATCHED THEN insert(herd_owner_id,herd_id,bhid)
VALUES(2,t2.tattoo,t2.bhid)
;
By looking in the appropriate syscat tables, I have determined it is
unhappy with a value assigned to t1.herd_id, which in t2.tattoo. The
merge statement explicitly requires that value to be NOT NULL. At least
I think so: the ON condition is negated by the NOT MATCHED clause. By
DeMorgan's Theorem NOT(a OR b OR c) is the same as NOT(a) AND NOT(b) AND
NOT(C). In the case at hand that translates to t2.bhid<>t1.bhid AND
t2.assoc='AN' AND t2.tattoo IS NOT NULL. Obviously I don't understand
something about the syntax or the semantics of the merge statement. Any
form of enlightenment, including RTFM (as long it points to a particular
place) would be greatly appreciated