fhg
Volume 8, Number 18 -- May 7, 2008

Replace the Contents of a Physical File That Has Triggers

Published: May 7, 2008

Hey, Ted:

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!

--Tricia


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) +
        TOFILE(MYLIB/MYFILE) MBROPT(*REPLACE)

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) +
            TRGLIB(MYLIB) STATE(*ENABLED)

--Ted




Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement