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


Chapter 3 Tools : FORALLB

FORALLB
Returns the next table occurrence that satisfies the selection criteria following a call to FORALLA. (C)
Invocation
CALL FORALLB(table)
 
This is a string specifying the name of the table to retrieve from. It is syntax C (fixed-length character string) and length 16.
Prerequisites
Before FORALLB can be called the table must be initialized by a call to FORALLA.
Usage Notes
FORALLB continues to retrieve occurrences based on the selection and ordering criteria specified in the call to FORALLA. After one initial call to FORALLA, FORALLB can be called repeatedly to retrieve multiple occurrences from a table.
To use FORALLB to retrieve all the occurrences in the table that match the selection criteria specified in a preceding call to FORALLA, call FORALLB within a loop created by an UNTIL TABLEEND statement. FORALLB continues to retrieve occurrences until there are no more occurrences that satisfy the criteria. At that point, FORALLB raises the TABLEEND exception and the loop exits.
There are a maximum of 16 tables that can be actively accessed with FORALLB per transaction. When you are finished accessing a table, you should call FORALLE to indicate that you are finished and to free up a slot for another table to be accessed.
See Also
TIBCO Object Service Broker Programming in Rules for information on the rules language.

Exception
 
Example
Using the following rule, QUERY_EMPS, users can construct a query against the EMPLOYEE table. The rule retrieves employee names based on the selection criteria associated with one field or with a combination of two fields and prints them to the message log. Users can execute the rule directly, or the rule could be part of a larger application in which input values are entered via a screen.
The rule supports queries such as:
The QUERY_EMPS Rule
QUERY_EMPS pads input data to appropriate lengths, constructs a FORALLA statement using the data from one or two fields, and then uses FORALLB, FORALLE, and MSGLOG to retrieve and display the names of all employees meeting the selection criteria in the FORALLA statement.
The FORALLB statement at action 8 in the Y column shows the use of an UNTIL TABLEEND loop.

 
RULE EDITOR ===> SCROLL: P
QUERY_EMPS(REGION, FIELD1, OPER1, VALUE1, ORD1, OPER3, FIELD2, OPER2,
_ VALUE2, ORD2);
_ LOCAL REGLEN, VALLEN1, VALLEN2, FLD1, OP1, FLD2, OP2;
_ ---------------------------------------------------------------------------
_ OPER3 = ''; | Y N
_ ------------------------------------------------------------+--------------
_ REGLEN = PAD(LENGTH(REGION), 2, '0', 'R'); | 1 1
_ VALLEN1 = PAD(LENGTH(VALUE1), 2, '0', 'R'); | 2 2
_ VALLEN2 = PAD(LENGTH(VALUE2), 2, '0', 'R'); | 3
_ FLD1 = PAD(FIELD1, 16, ' ', 'L'); | 3 4
_ FLD2 = PAD(FIELD2, 16, ' ', 'L'); | 5
_ OP1 = PAD(OPER1, 2, ' ', 'R'); | 4 6
_ OP2 = PAD(OPER2, 2, ' ', 'R'); | 7
_ CALL MSGLOG(FIELD1 || ' ' || OPER1 || ' ' || VALUE1 || ':' | 5
_ ); |
_ CALL MSGLOG(FIELD1 || ' ' || OPER1 || ' ' || VALUE1 || ' ' | 8
_ || OPER3 || ' ' || FIELD2 || ' ' || OPER2 || ' ' || |
_ VALUE2 || ':'); |
_ CALL MSGLOG(' '); | 6 9
_ CALL FORALLA('EMPLOYEE', REGLEN || REGION, ' R' || FLD1 || | 7
_ ' V' || VALLEN1 || VALUE1 || OP1, FLD1 || ORD1); |
_ || VALLEN2 || VALUE2 || OP2 || ' ' || OPER3, FLD1 || |
_ ORD1 || FLD2 || ORD2); |
_ UNTIL TABLEEND : | 8 B
_ CALL MSGLOG(EMPLOYEE.LNAME); |
_ CALL FORALLB('EMPLOYEE'); |
_ END; |
_ CALL FORALLE('EMPLOYEE'); | 9 C
_ CALL ENDMSG('PRESS PF2 FOR LIST');   | A D
_ ---------------------------------------------------------------------------
_ ON TABLEEND :
_ CALL FORALLE('EMPLOYEE');
_ CALL ENDMSG('NO MATCHING OCCURRENCES FOUND');
PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
Query
To find which employees working for manager number 79912 have a salary of more than $700.00, the following input values are supplied:

 
------------------------ H U R O N RULE EXECUTION -----------------------
ENTER ARGUMENTS FOR RULE QUERY_EMPS
REGION ===> midwest
FIELD1 ===> mgr#
OPER1 ===> =
VALUE1 ===> 79912
ORD1 ===> a
OPER3 ===> &
FIELD2 ===> salary
OPER2 ===> >
VALUE2 ===> 700
ORD2 ===> a

 
The message log displays the following employee names, arranged in order of ascending salary:

 
----------------------- INFORMATIONAL MESSAGE LOG --------------------
COMMAND ===> SCROLL ===> P
MGR# = 79912 & SALARY > 700:
HRODEK
BOIVIN
SCHULTZ
WONG

 

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