![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |
Task C: Create Rules to Populate the TDS Table using Data from the External Data SourceIn this task you will create a rule called SET_SCHEDULE that populates the GAME_SCHEDULE table, using information imported from the GAME_INFO table. You will also create a rule called INSERT_GAME that inserts the data into the database.A FORALL statement, which is used here, is a looping construct in the rules language. The entire FORALL loop only has one action, as shown by the Action Number “1”, associated with it. Consequently, all the statements between FORALL and END statements are repeated for each occurrence (row) in the table GAME_INFO.Inside the FORALL loop, the assignment statement (tablename.*=tablename.*) assigns the value of each field from the import table GAME_INFO to the field with the same name in the table GAME_SCHEDULE. The fields that do not have the same names will be ignored.Once the fields are effectively copied from one row in GAME_INFO to the row in GAME_SCHEDULE, another rule, INSERT_GAME, is called to perform an insert into the database.
• The only action statement inserts the content of the row as set in the calling rule SET_SCHEDULE into the table GAME_SCHEDULE.
− If the insert operation causes the number of outstanding updates on behalf of the transaction to become too big, the updates will be propagated to the database and changes made permanent using the COMMIT statement. For more information about transaction processing and the COMMITLIMIT exception see the TIBCO Object Service Broker Programming in Rules manual.
− If the insert fails, and the INSERTFAIL system exception is raised (such as the row inserted has a duplicate key), the exception is caught inside the inner rule, a message is printed to the TIBCO Object Service Broker message log, and then control is returned to the outer calling rule and processing of the loop continues.This illustrates how by the positioning of the exception handler, the programmer directs the processing flow in case of an error: If we wish to stop further inserts when any of the insert operation fails, the exception handler will be placed in the outer SET_SCHEDULE rule.
![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |