Home » Developer & Programmer » Forms » trigger to capture the user details (oracle forms 6i)
trigger to capture the user details [message #539540] Mon, 16 January 2012 22:41 Go to next message
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 #539542 is a reply to message #539540] Mon, 16 January 2012 23:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68683
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It depends on which user details you want.

Regards
Michel
Re: trigger to capture the user details [message #539543 is a reply to message #539542] Mon, 16 January 2012 23:37 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
thanks for reply me,

i want the user details who are performing the transactions.

ex:
now i am entering the data into it. it has to capture my details
if someone means their details. like wise updation and deletion cases.

thanks in advance
Re: trigger to capture the user details [message #539550 is a reply to message #539543] Tue, 17 January 2012 00:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68683
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Sorry, I don't understand.

Regards
Michel
Re: trigger to capture the user details [message #539552 is a reply to message #539550] Tue, 17 January 2012 01:46 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member

it's ok

thank you
Re: trigger to capture the user details [message #539578 is a reply to message #539552] Tue, 17 January 2012 04:34 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

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 #539581 is a reply to message #539552] Tue, 17 January 2012 04:41 Go to previous messageGo to next message
John Watson
Messages: 8949
Registered: January 2010
Location: Global Village
Senior Member
Quote:
capture the user details
But which details? Shoe size?
Re: trigger to capture the user details [message #539601 is a reply to message #539581] Tue, 17 January 2012 05:58 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
i have a student table like below

create table student_credentials(sno number(4),
sname varchar2(40),
user_name varchar2(30),
when_created date);
and my table structure is

Name Null Type
------------ ---- ------------
SNO NUMBER(4)
SNAME VARCHAR2(40)
USER_NAME VARCHAR2(30)
WHEN_CREATED DATE

now,through forms i am entering details only into sno and same . remaining 2 column details i have to capture programmatically. in the scenarios like, if any user insert details into this table through forms their details has to be in the user_name and when_created columns. like wise for update and delete.

Re: trigger to capture the user details [message #539602 is a reply to message #539601] Tue, 17 January 2012 06:03 Go to previous messageGo to next message
John Watson
Messages: 8949
Registered: January 2010
Location: Global Village
Senior Member
Quote:
like wise for update and delete.
update, OK. But delete? Confused
Re: trigger to capture the user details [message #539604 is a reply to message #539540] Tue, 17 January 2012 06:25 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Check the Transactional Triggers. I am sure your problem will be solved.
Re: trigger to capture the user details [message #539605 is a reply to message #539602] Tue, 17 January 2012 06:26 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
entirely for dml operations
Re: trigger to capture the user details [message #539606 is a reply to message #539605] Tue, 17 January 2012 06:28 Go to previous messageGo to next message
John Watson
Messages: 8949
Registered: January 2010
Location: Global Village
Senior Member
Er... what value do you expect the columns to have when the row has been deleted?
Re: trigger to capture the user details [message #539607 is a reply to message #539604] Tue, 17 January 2012 06:29 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member

thanks for reply me
can you suggest me anyone in the transactional triggers.

Re: trigger to capture the user details [message #539608 is a reply to message #539605] Tue, 17 January 2012 06:30 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Tell me is all of this story needs to be done through forms. If yes then again my answer is check Transactional triggerrrrrr...!
Re: trigger to capture the user details [message #539609 is a reply to message #539607] Tue, 17 January 2012 06:31 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
yes, it's not possible in case of delete.

anyway then what about the remaining two.
Re: trigger to capture the user details [message #539611 is a reply to message #539609] Tue, 17 January 2012 06:34 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
ok thanks for all to reply me.
Re: trigger to capture the user details [message #539662 is a reply to message #539611] Tue, 17 January 2012 12:23 Go to previous messageGo to next message
cookiemonster
Messages: 13938
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 #539683 is a reply to message #539662] Tue, 17 January 2012 22:28 Go to previous messageGo to next message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
good morning cookiemonster,

thanks for reply me,

i tried ,this is the code i written in pre-insert trigger in block level.
"insert into student_credentials values(:block_name.sno,:block_name.sname,user,sysdate);"

but it will inserting two rows into the table like this.

sno sname user_name when_created
------ -------- ------ ---------------
100 naresh bad111 18-JAN-12
100 naresh (null) (null).

can you tell me what's the problem here.

thanks in advance.
Re: trigger to capture the user details [message #539704 is a reply to message #539683] Wed, 18 January 2012 03:12 Go to previous messageGo to next message
cookiemonster
Messages: 13938
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.
Re: trigger to capture the user details [message #539730 is a reply to message #539704] Wed, 18 January 2012 05:04 Go to previous message
nareshvictory
Messages: 52
Registered: December 2011
Location: chennai
Member
thank you cookiemonster

it's working fine.

Previous Topic: when_button_pressed (4 threads merged by bb)
Next Topic: Do Compile while the form is open
Goto Forum:
  


Current Time: Mon Sep 16 06:10:26 CDT 2024