|
|
![]() |
|
|
|
|
||
|
V5 and Trigger Programs Hey, Ted: At my shop, we upgraded from V4R5 to V5R2. Now when anyone accesses a database file that has a trigger attached to it, we get a data decimal error in the trigger program. Do you have any suggestions on how to solve this problem?
-- Duane This is a well-known problem, Duane. I should take this opportunity to publicize this problem once again. Maybe another warning will help someone else. A trigger program receives two parameters, the first of which is a data structure that contains, among other things, before and after images of the record and before and after maps of null-column indicators. You have hard-coded the locations of the before and after record images in your data structure. With V5R1, IBM moved the location of the record images and null maps to other places in the data structure. You could update the data structure with the new record image locations, but I think that would be a mistake. IBM may move the record images again some day. Instead, you need to change the way you are accessing the record images. The data structure that contains the record images and null maps also includes subfields that indicate the locations of the record images and null maps. You need to modify your trigger programs so they use the offsets in these subfields. Here is an example from which you can begin. This program contains three pointers. If you're not used to pointers, don't let them scare you. The first eval equates the data structure that breaks down the trigger buffer to the first parameter. This gives you access to the subfields. The second eval equates the data structure that contains the before (old) record image to the before image in the parameter. This gives you access to the before image. The last eval equates the data structure that contains the after (new) record image to the after image in the parameter.
* Trigger program for purchase order master file POMASTR
*entry plist
D Trigger01 pr extpgm('POTRG02')
D 1024
D 10i 0
D Trigger01 pi
D TriggerBuffer 1024
D TriggerBufLen 10i 0
* Subfields from trigger buffer
D pTriggerBuffer s *
D WorkBuffer ds 1024 based(pTriggerBuffer)
D OldRecOffset 49 52i 0
D OldRecLen 53 56i 0
D NewRecOffset 65 68i 0
D NewRecLen 69 72i 0
* old & new record images
D pOld s *
D OldRec e ds extname(POMASTR) prefix(o)
D based(pOld)
D pNew s *
D NewRec e ds extname(POMASTR) prefix(n)
D based(pNew)
C eval pTriggerBuffer = %addr(TriggerBuffer)
C eval pOld = %addr(WorkBuffer) + OldRecOffset
C eval pNew = %addr(WorkBuffer) + NewRecOffset
-- Ted
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |