Home » Developer & Programmer » Forms » Maintaining Log at User level
Maintaining Log at User level [message #159551] Mon, 20 February 2006 04:28 Go to next message
manyal
Messages: 84
Registered: March 2005
Member
Dear Friend,

I want to have log (which maintains the user who is going to update the record)for each and every updation of records.for this every user is provided with one user code to be stored at table while updation.

so what are the most suitable triggers at block level to accomplish this requirenment.


Thanx in Advance
Re: Maintaining Log at User level [message #159656 is a reply to message #159551] Mon, 20 February 2006 17:05 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I suggest that you do this as a trigger in the database.

David
Re: Maintaining Log at User level [message #159675 is a reply to message #159656] Mon, 20 February 2006 21:58 Go to previous messageGo to next message
manyal
Messages: 84
Registered: March 2005
Member
Dear DJartin,

I m using form 6i as a front end and i also tried with triggers like when validate record and Post record but these triggers fires even i execute the record without updating it .


Manyal
Re: Maintaining Log at User level [message #159700 is a reply to message #159675] Mon, 20 February 2006 23:50 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I repeat - do it in the database.

David
Re: Maintaining Log at User level [message #159743 is a reply to message #159700] Tue, 21 February 2006 03:11 Go to previous messageGo to next message
rnemkul
Messages: 35
Registered: February 2006
Member
I agree with David So Use Database trigger using after

Rajendra
Re: Maintaining Log at User level [message #159848 is a reply to message #159743] Tue, 21 February 2006 22:00 Go to previous messageGo to next message
manyal
Messages: 84
Registered: March 2005
Member
Dear David and Rajendra,

when i use database trigger than can u plez tell me how i wud update user code column in my table as user is authenticated at form level.


manyal
Re: Maintaining Log at User level [message #159851 is a reply to message #159848] Tue, 21 February 2006 22:09 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You should be authenticating the user BEFORE they update the record. If they are not authorised then they either don't get (can't see) the record or it is presented with update turned off.

The "user code column" is updated IN the trigger.

David
Re: Maintaining Log at User level [message #159883 is a reply to message #159551] Wed, 22 February 2006 01:40 Go to previous messageGo to next message
rnemkul
Messages: 35
Registered: February 2006
Member
Here is a example below so you see the example
You have to write Condition for each and every column contaning on table. what you want to store log

CREATE OR REPLACE TRIGGER TRIG_adit
AFTER INSERT OR DELETE ON <TABLE_NAME>
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
BEGIN
IF INSERTING THEN
IF :NEW.<COL_NAME1> IS NOT NULL THEN THEn
INSERT INTO adit_TABLE(col1,col2)
VALUES('a','b');

END IF;IF :NEW.<COL_NAME2> IS NOT NULL THEN THEn
INSERT INTO adit_TABLE(col1,col2)
VALUES('a','b');
END IF;
ELSIF UPDATING THEN
IF :NEW.<COL_NAME1> IS NOT NULL AND :NEW.<COL_NAME><>:OLD.<COL_NAME> THEN THEn
INSERT INTO adit_TABLE(col1,col2)
VALUES('a','b');
END IF;
IF :NEW.<COL_NAME2> IS NOT NULL AND :NEW.<COL_NAME><>:OLD.<COL_NAME> THEN THEn
INSERT INTO adit_TABLE(col1,col2)
VALUES('a','b');
END IF;
END IF;
END;


Regards
Rajendra
Re: Maintaining Log at User level [message #160035 is a reply to message #159883] Wed, 22 February 2006 22:06 Go to previous messageGo to next message
manyal
Messages: 84
Registered: March 2005
Member


Dear Rajendra,

you mentioned database trigger but how i wud pass bind variable from form as a value in case of database trigger .


Manyal.
Re: Maintaining Log at User level [message #160037 is a reply to message #160035] Wed, 22 February 2006 22:14 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
What bind variable would you want to pass? The trigger has the whole record, it has access to all system variables including user, plus is able to run any functions or procedures that you have written, so any derivable variable is also available.

David
Re: Maintaining Log at User level [message #160093 is a reply to message #159551] Thu, 23 February 2006 03:31 Go to previous messageGo to next message
rnemkul
Messages: 35
Registered: February 2006
Member
Dear manyal
You mention message is not clear so what you want write in brief

Rajendra
Re: Maintaining Log at User level [message #160111 is a reply to message #160093] Thu, 23 February 2006 05:34 Go to previous messageGo to next message
manyal
Messages: 84
Registered: March 2005
Member
Dear rajendra,

i m having one data entry form which can be run only by authenticated users.

whenever user run form and do data entry user code is assigned to modified_by column to maintain log (user code is derived from the authenticated entry,every user is provided with a login name and password).
suppose next time another user is doing entry than new user code is overwritten to the modified_by column.

my problem is that new user is overwritten everytime whereas i want it to be overwriiten only in the case of updation and not in the case when user is just querying the record.



Manyal
Re: Maintaining Log at User level [message #160212 is a reply to message #160111] Thu, 23 February 2006 22:23 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Then put the code in the pre-insert and pre-update triggers, or LEAVE IT TO THE DATABASE TRIGGER.

David
Previous Topic: forms 9i questions
Next Topic: Why do Users get error Ora-06508 after form elevation
Goto Forum:
  


Current Time: Fri Sep 20 04:51:49 CDT 2024