Reputation: 17
I currently need to add to tables that update each time the user clicks the "Save" button on a program that updates any of their information. When any of the fields are amended, in order that we have a log of the changes, I need to create a record on a "slinfo" table including things like:
Customer name (slinfo.name)
Customer account (slinfo.acode)
The date (slinfo.date)
And slinfo.seq, which is the sequence number for each change.
How would I go about doing something like this?
Upvotes: 0
Views: 179
Reputation: 1266
you can handle this with Database Triggers https://documentation.progress.com/output/ua/OpenEdge_latest/pdsoe/PLUGINS_ROOT/com.openedge.pdt.langref.help/rfi1424920170039.html
you have also access to the old field value and the new field value in the trigger statement
simple write procedure:
TRIGGER PROCEDURE FOR WRITE OF Customer
CREATE slinfo.
ASSIGN
slinfo.name = Customer.NAME
slinfo.acode = Customer.account
slinfo.date = TODAY
slinfo.seq = NEXT-VALUE(seqSlinfo)
.
Upvotes: 1
Reputation: 14020
/* presumably you already have a save trigger to save the amended values
* this code should go in that trigger, probably at the end
*/
/* I, obviously, have no way to know where the actual values for
* these variables are supposed to come from. if the logic for
* that is simple enough you might even be able to eliminate the variables
*/
define variable nameVariable as character no-undo.
define variable acodeVariable as character no-undo. /* I'm guessing that this is a character field */
define variable seqVariable as integer no-undo.
/* do something to populate the variables...
*/
/* since you are apparently already saving changes to slinfo
* you just need to add a few fields
*/
assign
slinfo.name = nameVariable
slinfo.acode = acodeVariable
slinfo.date = today
slinfo.seq = seqVariable
.
Upvotes: 0