I am trying to update a file using a trigger program, at insert, *before. Using debug I can watch all data movements.
In the pgm, I simply move a value to a field in the new record buffer. As I understand, the new record buffer is what is used to insert new data values. However, the recorded does not update.
I am missing something very simple, but cannot find the answer. Here is the shortened version of coding. Can you help me?
* * * TRIGGER BUFFER * * DBuffer DS 32767 . . . D 3 D TrgCCSID 10U 0 D 8 D NwOffset 10U 0 D NwRcdLen 10U 0 . D* * * BUFFER LENGTH, (value of) * * * DBufferLen S 10U 0 . * * * ORIGINAL AND NEW RECORD IMAGES. * Original Record D@OrRecord S * Inz(Null)DOrRecord E DS ExtName(EOITA) Prefix(OR_) D Based(@OrRecord) *New Record D@NwRecord S * Inz(*Null) DNwRecord E DS ExtName(EOITA) Prefix(NW_) D Based(@NwRecord) . . . * Assign the record templates to their data space C Eval @OrRecord = %Addr(Buffer) + OrOffset C Eval @NwRecord = %Addr(Buffer) + NwOffset . . . Eval NW_TARID = 'TA' That's it....
New record field TARID should now reflect new value of 'TA' literal. Buffer does. However, after program ends, field contain value of original field's value, not the modified value. Please, can you see what I am overlooking in this simple program? How, or when does the new record buffer update?
Several years ago I tried the same thing with results similar to yours. What I found is that the trigger buffer in your RPG program is an input only copy of the trigger buffer and the actual trigger buffer is not modifiable from the trigger program. The Redbook, "Stored Procedures and Triggers on DB2 Universal database for Iseries" talks about this in section 10.3 on page 302.
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.
Dig Deeper on RPG iSeries programming
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.