Home

Resources
 
Index Listing Spreadsheet....

I do a lot of consulting a legacy shops, and most of the time it is SQL performance consulting.  When you are looking at the performance of a statement, it helps to know what logical files, (indexes), are available to the query optimizer that can be used for statement implementation.  The problem is that most legacy shops have very obscure naming conventions for their fields, so divining the intent of the index can be quite difficult.  Most of the time, these legacy shops have column text descriptions of their fields that are more human readable and understandable, and since I do not like the output of DSPFFD, and that requires having a green screen up, I created the index listing spreadsheet so I could get a nice printed report of the indexes available for the resolution of my queries along with the column text explanation of the field.

Click Here to download the spreadsheet.

How it works

The spreadsheet is implemented using ADO, ODBC and the VBA Macro language in Excel.  When you open the spreadsheet, you should see the first tab with a table like the following displayed:

  AS/400 Table and Index Lister
Library HD1100PD
Table Name ARPMBCH
Data Source MYAS400
User ID HARNER
Password SECRET
 

 

 
   

What you do is enter the name of the library into the Library field, the table name you want information on into the Table Name field, identify a valid ODBC data source, (created via the ODBC Data Sources applet in the control panel), and enter your user ID and Password.  Next, you can press either the List Indexes or List Columns. The following text describes the code that is executed for each of the buttons.

List Columns

This button is linked to a macro called GetTableInfo.  The macro creates a connection to your AS/400 via the data source name that you specified and then uses the OpenSchema method of the connection object to return the adSchemaColumns resultset for that identified table.  The macro then reads each record in the result set and formats a pretty spreadsheet of the columns in your table including the table text.  The resulting spreadsheet it suitable for framing!

List Indexes

This button is lined to a macro called GetIndexInfo.  The macro creates a connection to the AS/400 and then gets a recordset of all of the columns in the target table.  This recordset is then disconnected from the AS/400 to allow for programmatic "adjustment" on the client computer.  Next, the macro uses the OpenSchema method of the connection object to return a list of indexes, (logical files suitable for SQL query processing), and for each entry prints a pretty report of the indexes.  During the printing of an individual column of index information, the macro uses the Filter property of the disconnected columns recordset in order to look up the defined column text for the column it is printing.  Becasue this is a disconnected recordset, this lookup involves no additional communications with the AS/400 and is therefore quite fast.

Click Here to view more information on disconnected recordsets.

Sample Listing of Indexes

Available Indexes
HD1100PD/ARPMBCH
       
Index Name Unique? SortSeq ColName Description
ARLMBCH7 FALSE Asc ARNO15 Company Number
  Asc GLCD41 Division Code
  Asc GLCD42 Region Code
  Asc ARNO16 Branch Number
       
ARLMBCH1 FALSE Asc ARNO15 Company Number
  Asc ARNO16 Branch Number
       
ARLMBCH3 FALSE Asc ARID03 Branch Master ID
  Asc ARNO15 Company Number
       
ARLMBCH2 FALSE Asc ARNO16 Branch Number
       
ARLMBCH4 TRUE Asc ARNO16 Branch Number
       

Sample Listing of Columns

Columns Listing
HD1100PD/ARPMBCH
             
Name   Type Len Prec Scale Nulls? Description
ARNO15 0 Numeric   3 0 N Company Number
ARCD14 0 Numeric   2 0 N Geo. Sales Area
ARCD15 0 Numeric   2 0 N Geo. Sales Zone
ARCD04 0 Numeric   7 0 N Customer Tax Jurisdiction Code
ARNO16 0 Numeric   3 0 N Branch Number
ARNM07 0 Char 25     N Branch Name
ARAD07 0 Char 30     N Branch Mailing Address 1
ARAD08 0 Char 30     N Branch Mailing Address 2
ARAD09 0 Char 30     N Branch Mailing Address 3
ARCY03 0 Char 25     N Branch Mailing City
ARST03 0 Char 2     N Branch Mailing State
ARZP17 0 Char 10     N Branch Main Mailing Zip Code
ARAD10 0 Char 30     N Branch Shipping Address 1
ARAD11 0 Char 30     N Branch Shipping Address 2
ARAD12 0 Char 30     N Branch Shipping Address 3
ARCY04 0 Char 25     N Branch Shipping City
ARST04 0 Char 2     N Branch Shipping State
ARZP18 0 Char 10     N Branch Main Shipping Zip Code
ARNO17 0 Numeric   3 0 N Branch Telephone Area Code Number
ARNO18 0 Numeric   3 0 N Branch Telephone Prefix Number
ARNO19 0 Numeric   4 0 N Branch Telephone Suffix Number
ARFL16 0 Char 1     N Branch Closed Flag
ARNM03 0 Char 10     N User ID Of Maintenance
ARMO09 0 Numeric   2 0 N Month Of Last Update
ARDY09 0 Numeric   2 0 N Day Of Last Update
ARCC09 0 Numeric   2 0 N Century Of Last Update
ARYR09 0 Numeric   2 0 N Year Of Last Update
ARID03 0 Char 3     N Branch Master ID
ARCD69 0 Char 3     N Not used
ARCD70 0 Char 3     N Not used
ARFL23 0 Char 1     N Operational Branch Flag
ARCDD8 0 Numeric   3 0 N Branch Backorder Priority
ARCDD0 0 Char 1     N Allow Backorders
GLCD41 0 Char 3     N Division Code
GLCD42 0 Char 3     N Region Code
ARFL75 0 Char 1     N Using On-Line Credit CardProcessing
ARNOB5 0 Numeric   2 0 N Number of Credit Card Settlement Networks