iNTERFACEWARE Products Manual > Learning Center > Tutorials and Sample Scenarios > Routing and Processing Messages > Data Validation > Solution Two: Using A Database Trigger |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
This second solution is a little more complex and involves writing a Trigger for your database. This is an example of a trigger written for an Oracle database using the Oracle PL/SQL language (this code was compiled cleanly and tested on Oracle Database 9.2 using WinSQL to send the query). The trigger is executed when an A04 Registration insert/update needs to be done on the database. We want to verify that the PRK/MRN combination in the message matches the stored values in the PID table. The data checking results decide if a new record should be inserted or an existing record updated or simply an error reported. Three tables exist for this example - REGISTRATION_TABLE_TEMP, REGISTRATION_TABLE and PID. The data is sent to the REGISTRATION_TABLE_TEMP. The conditions are checked and the appropriate insert/updates are made to REGISTRATION_TABLE and PID (if any). We may add code to periodically clean the table REGISTRATION_TABLE_TEMP so that it remains small.
|