DB2: How to get generated always as statement to work with session user
问题 I need to get a userstamp into a table and have not managed to figure out how the GENERATED FOR EACH ROW ON UPDATE AS statement works with the SESSION_USER variable in DB2 10.5 (LUW). Managed to get an implementation working using a function which has a fake variable for forcing the evaluation in update statements: CREATE OR REPLACE FUNCTION XXX.CURRENT_USER( tmp varchar(128)) SPECIFIC xxx.XXX_CURRENT_USER RETURNS VARCHAR(128) CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION BEGIN RETURN session