Can an Oracle database trigger know what user is actually logged into the system?
Posted on 2008-11-06
I hope I understand this enough to pose an intelligent question.
- I'm working on a web-based application written in J2EE which interfaces to an Oracle database.
- Users log into the system using their network password.
- A table in the database contains a "created by" column which is supposed to contain the user name of the person who created the row.
- When a form writes to the table, a trigger is fired which automatically includes the created_by and created_time columns using the system variable USER.
The system variable USER contains the user name of the account used to connect to the database (which is the same for everybody) and NOT the name of the user who is actually logged into the application.
I realize that J2EE can pass the username of the person actually logged into the system, which the trigger can then use to insert this information into the database, but is there another way for the (in this case) Oracle database trigger to obtain the user name of the person actually logged in?
(If the username is not part of the data used to perform the insert, can my trigger somehow obtain it?)