Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 5 Manipulating Import Data Using TIBCO Object Service Broker : Sample Rules

Sample Rules
Sample Rule 1: Normal Access
The following example illustrates a sample rule for normal access to import data.

 
RULE EDITOR ===> SCROLL: P
EMPLOYEE_A;
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ FORALL EMPLOYEE_A : | 1
_ DEPARTMENT.DEPTNAME = EMPLOYEE_IMP.DEPTNAME; |
_ INSERT DEPARTMENT; |
_ END; |
_ ---------------------------------------------------------------------------












PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
Sample Rule 2: Accessing Multiple Record Formats
The following example illustrates a sample rule for accessing multiple record formats. The tables in this rule are the ones defined in Table Definitions.

 
RULE EDITOR ===> SCROLL: P
EMPLOYEE_B;
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ FORALL EMPLOYEE_IMP_A : | 1
_ FORALL EMPLOYEE_IMP_B(EMPLOYEE_IMP_A.KEY) : |
_ CALL MSGLOG(EMPLOYEE_IMP_B.LNAME); |
_ END; |
_ END; |
_ ---------------------------------------------------------------------------











PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
Explanation of the EMPLOYEE_B Rule
To access multi-record formats, a parent import table and one or more child import tables must be defined. In the EMPLOYEE_B rule definition, you need two tables: one for the parent (EMPLOYEE_IMP_A) and a second for the child (EMPLOYEE_IMP_B).
The parameter value of the EMPLOYEE_IMP_B table ensures that all the record formats for this file are accessed from a single physical record.
To access the record B data, you must first access the parent record A data. This causes the import record to be read into a buffer and an internal cursor set to determine the positioning of data being accessed within the buffer.
In this rule, the FORALL EMPLOYEE_IMP_A: causes the first record to be read and buffered. The data contained within the format A record is returned to the rule and the cursor set to the end of the record data A area (in this case the first record B data portion).
The second FORALL EMPLOYEE_IMP_B(EMPLOYEE_IMP_A.KEY): then returns the first format B data and moves the cursor to the next piece of data (in this case, the second record format B data). Employee last names are written into the message log. This continues until the data within the buffer is exhausted. At this point, the second FORALL terminates and the next parent record A is retrieved by the first FORALL statement.
The parent import occurrence must always be accessed prior to any child table. If the child import table is accessed first, the GET or FORALL operation fails as no current occurrence is buffered and the internal cursor is undefined.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved