Replace the Contents of a Physical File That Has Triggers
Published: May 7, 2008
I need to copy the contents of a physical file from our production system to its counterpart in our development system, which is a separate logical partition. I have several ways to copy the file from the production system to the development system. However, error messages I get say that I cannot replace the data because the database file has triggers over it. Help!
You need to disable the triggers. Disabling triggers is most easily done if all of the triggers are active. Use Change Physical File (CHGPF) to disable the triggers.
CHGPFTRG FILE(MYLIB/MYFILE) TRG(*ALL) STATE(*DISABLED)
Then copy the data.
CPYF FROMFILE(YOURLIB/YOURFILE) +
And re-enable the triggers.
CHGPFTRG FILE(MYLIB/MYFILE) TRG(*ALL) STATE(*ENABLED)
If the file has one or more disabled triggers, note the names of the disabled triggers so that you will be able to re-enable the right ones. The easiest way is to run DSPFD ... OUTPUT(*PRINT) before disabling the triggers. Then you'll be able to enable or disable triggers one at a time, as illustrated by the following command.
CHGPFTRG FILE(MYLIB/MYFILE) TRG(AFTDELETE) +
Post this story to del.icio.us
Post this story to Digg
Post this story to Slashdot