473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

current user id

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
Nov 12 '05 #1
1 8083
Man, you're outdated.....

Anyway CURRENT USER is available in V7.
You are correct that global temp tables cannot be referenced in a trigger.
The application_id can be retrieved from the DBINFO structure.
There si an article on developerWorkks/DB2 by, I think, Paul Yip that
provides a Java UDF you can use to retrive it.
application_id() as a function is available in DB2 UDB for LUW V8 FP7
(aka V8.2).
To record session-level information for access in triggers you can use
the application_id() as a primary key in a persistent table.

Hope that helps
Serge
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
2
by: Jesper Stocholm | last post by:
I have implemented role-based security within my ASP.Net application. However, it seems the role is not passed to the authentication ticket I create. I want to use it to display/hide some...
4
by: Dan Bart | last post by:
I am using an application which is a modification of IBuySpy Portal. It is using Forms authentication. Users login and their name is added to Context Then I use: ...
8
by: Mark White | last post by:
Hey everyone I'm having a great deal of problems finding this information through google and yahoo, so I turn to you on this. I have a Windows app running on XP. I am able to caputre the...
4
by: Leszek | last post by:
Hello! I have my webpage (ASP) in domain (IIS 6.0). I need to make a popup with fullname of current user. How can I do this? Maybe someone have any examples? Thanks!
0
by: davidr | last post by:
Hi, I been stuck on this for a week or more. So please help! I have a menu were a user can click a button and a user control is loaded into the page. A problem occurs when trying to load a...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
4
by: Doogie | last post by:
Hi, I am using HttpContext.Current.User.Identity.Name to get a user id from a web application. I then use that as part of a name of a cookie I'm writing. 30 minutes later I do a refresh of this...
9
by: Alex | last post by:
Get the Name and Phone Number of the Current Windows User in a .NET Application I am writing a simple .NET (C#) application. It needs to "automatic" get the Name (last, first) and phone number...
13
by: bproddu | last post by:
Hi, I'm using Forms authentication for my web app. I've a custom Principal class that I would like to set to the HttpContext.Current.User after the Membership.ValidateUser() passes. I'm able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.