Hi,
DB2 v7.1 FP3 on Windows 2003
I am trying to acheive the following:
create trigger ADD_LHL
after insert on MAINTABLE
for each row mode db2sql
insert into LOGTABLE
(USRSEQ) values (select usrseq from session.usr )
When a user logs on to the database, a user temporary table is created with
declare global temporary table
usr
(
USRSEQ char(20)
)
on commit preserve rows not logged
When the trigger triggers, the user sequence of the currently logged on user
needs to be fetched from the temporary table and this code needs to be
inserted into the log table. As far as I can now tell, I cannot reference
global temporary tables in a trigger. Is this the case? Please note, all
users log on the the database with the same user, but the users log on to
our application using a username and password stored in one of our tables.
It is this username that I wish to use in the trigger.
Next question: if the above does not function, is there any other strategy I
can use to assign a user code in a trigger? One strategy I thought of is, to
retrieve the session id of the currently logged on user, but there does not
seem to be a SQL method available to get the user id that I see in the
control center when I have a look at the connections. I could save the
"current user" and the appropriate user code in a non-temporary table which
could then be referenced in the trigger. I think DB2 v8 has a "current user"
register that I could use for this, but I am limited to using functionality
in v7 . Any ideas?
Regards
Rudolf Bargholz