trigger to capture the user details [message #539540] |
Mon, 16 January 2012 22:41 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/169665.jpg) |
nareshvictory
Messages: 52 Registered: December 2011 Location: chennai
|
Member |
|
|
hi to all,
i have a table in that i have some columns along with that four columns to capture the user details. but these details must be captured Programmatically.like whenever a user insert or update or delete his credentials must be captured in these columns. but i am not figuring out in which trigger i have to write and how. can anybody tell me how it is possible.
thanks in advance.
|
|
|
|
|
|
|
Re: trigger to capture the user details [message #539578 is a reply to message #539552] |
Tue, 17 January 2012 04:34 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
ranamirfan
Messages: 535 Registered: January 2006 Location: Pakistan / Saudi Arabia
|
Senior Member |
![ranamirfan@gmail.com](/forum/theme/orafaq/images/google.png)
|
|
Dear,
Please Read this.
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/triggers.htm
How Column Lists Affect UPDATE Triggers.
Quote:
An UPDATE statement might include a list of columns. If a triggering statement includes a column list,
the trigger fires only when one of the specified columns is updated.If a triggering statement omits a column list, the trigger fires when any column of the associated table is updated. A column list cannot be specified for INSERT or DELETE triggering statements.The previous example of the PRINT_SALARY_CHANGES trigger can include a column list in the triggering statement.
For example:
... BEFORE DELETE OR INSERT OR UPDATE OF ename ON emp ...
Regards,
Irfan
[Updated on: Tue, 17 January 2012 04:41] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: trigger to capture the user details [message #539662 is a reply to message #539611] |
Tue, 17 January 2012 12:23 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
User_name would be user. When_created would be sysdate.
To set them in forms you would write some code to assign those values to those columns in the pre-insert and pre-update triggers.
Alternatively you would create database triggers to do the same thing - a before update row and a before insert row.
|
|
|
|
Re: trigger to capture the user details [message #539704 is a reply to message #539683] |
Wed, 18 January 2012 03:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The problem is you're writing an insert statement. Of course you get two rows. The pre-insert trigger doesn't stop forms doing it's normal insert.
Use the pre-insert trigger to assign to user and sysdate to the appropriate datablock items.
|
|
|
|