This example shows how the following scenario can be accomplished.
Every day five specific tables are reloaded, to check for new or updated data. After all these tables have been successfully loaded a csv file should be sent per mail, containing the view of these tables.
This means an action, in this case of the type ‘EXP_MAIL’, has to be triggered, every time the application status of the application containing all five tables as database objects changes to ‘FINISHED_TYPE = FINAL’. To do these, the following steps have to be implemented in that order.
Follow the steps of the following HowTo Guide to add an application:
After follwoing this guide, an application with the name 'test_app' will be added to REDADM.RED_APPLICATIONS.
To define a rule for adding objects to an application, one has to follow the steps of the first chapter of this HowTo Guide:
By defining the schema and table inclusion and exclusion search patterns the five tables we want to combine into a unit, to be able to check if all of them have been loaded successfully, can be added to an application.
The rule for the app 'test_app' can be found in REDADM.RED_APP_DISCOVER_RULES after following the guide mentioned in this chapter.
To be able to send the view data of the tables as a csv file per e-mail, a rule for formatting data into a csv format needs to be added. This can be done following the first chapter of this HowTo Guide:
After successfully having followed the HowTo Guide above an entry for the export format 'test_fmt' has been added to the table REDADM.RED_APP_ACT_EXP_FORMATS.
An action can be added using the API_REDADM.ADD_APP_ACTION script, however as in this example the goal is to add an action which exports the view data as a csv file, the script API_REDADM.ADD_APP_ACT_EXPORTS should be used. How to use that script is explained in the following HowTo Guide:
This Guide adds an action export into the database called 'test_exp' which will use the export format 'test_fmt' created in the step before to format all exports into a csv file.
Now all of the before created items can be combined into an application-action. One of these items is the application which has been created in step 1 and to which objects have been added in step 2, in this case the five tables that should be reloaded and checked together and therefore trigger the action. In step 3 an export format was created, so data can be send as a csv file and in step 4 the data which should be exported is being defined via the action export. In this step all of these items are combined by telling the database that if the application is triggered through one of the 5 tables belonging to it, the action export using the export format should be used to send a mail containing the data in a csv format to the recipients defined in this step, using the subject and body defined in one of the mail templates saved in REDADM.ADM_MAIL_PARAMS for the mail itself.
How exactly this is done, can be seen in the following HowTo Guide.
The mail action export can be found in the table REDADM.RED_APP_ACTIONS after having followed the guide above.