Home » Developer & Programmer » Forms » Insert and Update directly into table from pre update trigger of block based on same table (Forms 6i)
Insert and Update directly into table from pre update trigger of block based on same table [message #456059] Fri, 14 May 2010 06:10 Go to next message
kenibhoy
Messages: 3
Registered: January 2009
Junior Member
Hi, I have a base table (Table A) block with multiple records displayed. I need to track audits to this underlying table in the following way:

If user updates a field in the block I want the pre-changed record's audit fields to be set and I need to create a copy of the record with the changed values. Basically any changes will result in the record being logically deleted, and a copy record created with the newly changed values.

Tried to implement in the block's pre-update trigger which will call a package to directly update Table A then Insert into Table A, then requery the block.

Is there a clean and efficient way to do this?

Thanks
Re: Insert and Update directly into table from pre update trigger of block based on same table [message #456062 is a reply to message #456059] Fri, 14 May 2010 06:44 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you consider doing the same on the database level? Such as BEFORE UPDATE database trigger?
Re: Insert and Update directly into table from pre update trigger of block based on same table [message #456072 is a reply to message #456062] Fri, 14 May 2010 07:35 Go to previous messageGo to next message
kenibhoy
Messages: 3
Registered: January 2009
Junior Member
You mean like using :old values and :new values.

If i did that would it be setting :old audit values of table and inserting into same table using :new values? what knock on effect would that have?
Re: Insert and Update directly into table from pre update trigger of block based on same table [message #456079 is a reply to message #456072] Fri, 14 May 2010 07:58 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I think you need to explain your requirement in more detail, preferably with examples.
I'm struggling to understand exactly what you are trying to achieve here.
You don't normally insert audit information into the table you are auditing.
Re: Insert and Update directly into table from pre update trigger of block based on same table [message #456497 is a reply to message #456079] Tue, 18 May 2010 03:15 Go to previous message
kenibhoy
Messages: 3
Registered: January 2009
Junior Member
I found a solution:

PRE-UPDATE trigger on block calls a packaged procedure to logically delete the existing record then create a copy record from the new values on screen hence maintaining an audit trail
Previous Topic: Save only edited or new records
Next Topic: Problem with Graph in Forms 6i
Goto Forum:
  


Current Time: Fri Sep 20 08:27:44 CDT 2024