× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 31-Aug-2011 08:40 , Terry Anderson wrote:

We use a third party package to maintain our customer master file.
Corporate has decided to standardize on customer numbers across our
18 divisions. They want a way to prevent the divisions from creating
a customer record that uses a non-sanctioned customer number. I do
not want to modify the third party code if I can help it.

I have used trigger programs in the past to track changes to a file
but is there a way to use one to prevent a record from writing to a
file? If so, does someone have an example of how to do this they
would be willing to share?


In a *BEFORE *INSERT trigger, send a diagnostic message [IMO best results by sending previous to the program QDBPUT, which will be to the application requesting the insert\write] and then send an escape message previous to the trigger program itself [which will be QDBPUT]. The escape message will cause the database "put" processing to stop, i.e. preventing the write, and then signal CPF502B to the application program which requested the write. Assuming no radical changes to the database, the escape message will not be visible in a trace nor joblog, so what message [identifier] is used is irrelevant nor should there be any expectation that the information in that message will be available to any programs; that is the purpose of the diagnostic. Consider that a *BEFORE *UPDATE trigger might be required to enforce the same requirements.

Depending on what defines the standardization, a CHECK CONSTRAINT may be an alternate means to ensure the data being written [and updated] follows the rules. With more description of the column and data requirements, and if those requirements might not 'require' a trigger, someone may be able to provide a check-constraint definition which could be used instead of the trigger program(s). The I\O error for the failed write due to a violation of the check-constraint would be the message CPF502F.

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.