Hi, this is Kevin. We're continuing with Table Handling, Part 2. In the last lesson we built a table and loaded data into the table. During this lesson, we will use three examples of a sequential search that would be perform, perform varying and search. We're going to use search all for a binary search which is different than a sequential search. We're going to use subscripts and indexes within a table. We're going to use the SET statement, and also become familiar with a 2 dimensional table. The examples in this lesson are partial due to limited space. A table search using perform means the table is searched until a match is found or all rows were searched with no matches found. This is a sequential search. A table search using performed varying changes the previous sequential search example slightly. It combines a perform until with a built-in automatic incrementing for each successive perform iteration with the varying table subscript going from one by one clause near the bottom. Using an index for subscripting works differently. Index is not explicitly defined in working-storage. No worries. The computer will generate the code automatically. The index is created due to the occurs clause within each table. Notice the code begins with 01 Tax-Table, then 05 Taxes occurs 3 times with the phrase indexed by tax-index. We know that add, subtract, and move can modify subscripts but they can't modify indexes. No, what shall we do? On the top of the screen, you will see that indexes are modified or initialized by the word SET and syntax is first the word SET, then index-name. Then you get to choose up or to or down, then a number. You can set with a literal, a data field, or another index. Feel free to pause and look at the examples at the bottom of your screen. We are now taking a look at a table search using the search statement. Before we search, we must set the table index. The table is searched sequentially until the end of the table or the when condition is true. The index is automatically incremented. Elements in the table can be in any sequence that you wish. Feel free to pause and look at the example. A table search using search all as a statement uses a binary search which is faster than a sequential search. The elements also known as the rows have to be stored in sequence with an ascending key or a descending key. So what is a key? A key could be a name of somebody. It could be a number like an employee ID, or something like that. So, you have to identify what the key is and whether the data is in ascending order or descending order. You do not have to set the table index before the search like you have to do with a sequential search on the previous page. Now we get a look at a table binary search using search all and we will pause to see a part of the working-storage and the procedure division. Many organizational patterns for data require the use of multidimensional tables to model information accurately. For example, if it's an accounting period, we have to deal with both months and weeks. At a university, classes and students. Geographical data, states and cities. An historical data might have four levels, years, months, weeks, and days. COBOL can handle up to seven levels. The example on the next slide is that of a two-dimensional table. To create a two-dimensional table, simply define an occurs within an occurs variable definition. Let's suppose that the tax rates change each year and we want to build a table that will handle 5 years at a time. How will we do this? Look at your screen, tax-table is the highest group data item. State is the outer occurring group, with one elementary field. And year is the inner occurring group, with one elementary field. What would the data entries for five years look like? Let's see. On the screen, if we wanted to navigate a two-dimensional table to find the proper tax rate, we must first travel down, going top to bottom on the table to the position of one of the three tables that we have, either Arizona or New Jersey or California. Then once we've picked one of those states, then we're going to travel horizontally going from left to right or going across to one of the five years we desire to capture the correct rate for. For example, if we land on Arizona and we want to find out what the tax percentage is going to be in the year 2023, we move over to the 2023, and discover that it's going to be 7%. During this lesson, we discovered how to use three examples of a sequential search, perform, perform varying, and search. We also know how to use a search all for a binary search, how to use subscripts and indexes within a table. Use the SET statement and become familiar with a 2 dimensional table. We'll see you in the next session.