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


Chapter 9 Manipulating Storage Data Using TIBCO Object Service Broker MAP Tables : Using Rules to Access Storage Data

Using Rules to Access Storage Data
The following sections outline the differences encountered while using rules and also point out normal rules behavior that you must consider when building applications. The following rules statements are discussed:
These statements are all used to move data between the table buffer and an area in main storage.
Examples Used
It is assumed that the storage area to be accessed is at decimal location 1000. Although it is unlikely that the storage address would be known before runtime, this simplifies the examples. All example storage locations are in decimal format.
GET Statement
A GET statement returns a single occurrence from main storage. If no occurrence matches the selection criteria specified, the GETFAIL exception is raised.
Evaluation Process
TIBCO Object Service Broker uses the value of the address parameter as the address of the first row in main storage to be examined. This occurrence is assigned the key value of 1. If the occurrence satisfies the selection criteria, it is returned; otherwise, TIBCO Object Service Broker computes the address of the next occurrence in storage by adding the length of a table occurrence to the current address and increasing the key value by 1.
This process continues until either:
Examples of GET Statements
The following table illustrates examples of GET statements. The table definitions discussed in the examples are illustrated in Chapter 8, Managing TIBCO Object Service Broker MAP Data Definitions.
Retrieves the first row of table MAP_TWO starting at address 1000. The system assigns the field KEY the value 1.
Retrieves the same data from address 1036 as the previous example; however, the row number returned in KEY is 1. From this it can be seen that row numbers are not persistently related to storage addresses but are relative to the base address in the address parameter.
WHERE FIELD2=’ROBINSON’;
Returns the first row encountered where the value of FIELD2 is ROBINSON. If this value is not found in storage, the GET statement sweeps through main storage without limit, until TIBCO Object Service Broker or the operating system interrupts it. Therefore, you should limit the search; for example, if it is known that the row required should be within the first 100 records in storage, use the following example.
WHERE FIELD2=’ROBINSON’
Limits the search to the first 100 records. Avoid specifying a condition that appears to limit the search range but does not do so. Using a count parameter is the safest way of ensuring that the search always terminates predictably.
FORALL Statement
A FORALL statement is a looping construct that processes a set of occurrences. The body of the loop consists of the statements to be executed for each occurrence satisfying the selection criteria. FORALL statements can be nested, provided they refer to different table names.
A FORALL statement returns multiple occurrences from main storage. If no occurrences match the selection criteria specified, the FORALL ends without error.
A FORALL statement that attempts to reference unregistered storage causes the DATAREFERENCE exception to be raised. Occurrences are retrieved and examined as for a GET statement.
Examples of FORALL Statements
The following table illustrates examples of FORALL statements. The table definitions discussed in the examples are illustrated in Sample Definitions.
Returns any rows where FIELD3 begins with the string EMPL. Only the first five rows in storage are searched.
Considers only the first 5 rows to be eligible for searching for the EMPL* string; however, the key selection further restricts the search to those rows numbered higher than 3. In effect, only rows 4 and 5 are searched.
Returns records starting at location 1000. If the PROCESS_SAMPLE_DATA rule raises the FINISHED exception, the FORALL ends. If the FINISHED exception is not raised, the FORALL sweeps through registered storage unconstrained.
REPLACE Statement
The REPLACE statement copies a single row from the table buffer to main storage. The address parameter is used as the logical address of row 1 of the table.
Evaluation Process
The value of the key field of the table is used to identify the row to be replaced. TIBCO Object Service Broker computes the actual address by multiplying the key value minus 1 by the row length and adding the result to the address of logical row 1.
Examples of REPLACE Statements
The following table illustrates examples of REPLACE statements. The table definitions discussed in the examples are illustrated in Sample Definitions.
Replaces the content of storage from location 1000 to location 1011 with the value of the fields FIELD1 and FIELD2 of MAP_TWO.
Replaces the content of storage from location 1024 to location 1035 with the value of the fields FIELD1 and FIELD2 of MAP_TWO.
See Also
TIBCO Object Service Broker Programming in Rules for information on using table access statements.

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