×
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.
Hello all, in a DB2 table/file can you control with triggers if a
write/update (or SQL insert/update) is allowed based on a setup on another
table?, example:
Table1 - is a setup table that indicates if a client id is allowed to have
types of payments (check, card, eft, etc) to shorten this table will have
the client id, payment type and Y/N flag (Y - allowed, N - not allowed)
Table2 - is the payments table that has the client id, payment type,
payment amount, payment date, etc. this table is created from a batch load
we receive. This is the table that the trigger would go in.
The idea that I was asked to explore is: since we don't know all the other
'entry points' that could write/update Table2 such as APIs that call store
procs, user SQLs w/Insert or Update, Python, Java pgms, etc etc. Is if with
triggers we can control the write/update of recs.
So when a write/update is done on Table2 a trigger pgm would be called to
validate if based on Table1 the payment can be written into Table2. The
trigger would be something like this:
CREATE OR REPLACE TRIGGER TRG_TABLE2
BEFORE INSERT OR UPDATE ON MYLIB.TABLE2
REFERENCING NEW ROW AS N OLD ROW AS O
FOR EACH ROW MODE DB2ROW
BEGIN
CALL VALPGM1 (N.CLIENTID, N.PAYMENTTYPE);
END;
Up to this point I get it, but where I'm scratching my head is in the batch
load pgm that writes into TABLE2, how will it know that the write actually
allowed the record to be written when the client is not setup for that
payment type. Or if an external pgm added the recs as expected.
thank you
Ramon Sandoval
As an Amazon Associate we earn from qualifying purchases.
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.