cObject
---cTableColumnFetchHelper
The cTableColumnFetchHelper class allows you to create a helper object that makes it easy to enable or disable Selective Column Fetching (SCF) for a large number of tables in a database with a few simple methods.
The DataFlex Connectivity Kits support an interface that allows you to retrieve selected columns from a record. When used properly this can speed up some operations. You are most likely to see a speed difference when this is used in batch processes such as updates or reports and when the columns not fetched are Text. A command interface exists that allows you to:
1. Determine if a table should fetch all columns or fetch selected columns. The normal behavior for a table is to fetch all columns. This is controlled by the attribute DF_FILE_FETCH_ALL_COLUMNS and is used as follows:
Set_Attribute DF_FILE_FETCH_ALL_COLUMNS of iTable to True|False Get_Attribute DF_FILE_FETCH_ALL_COLUMNS of iTable to bFetchAll
2. If selected columns are fetched, the DF_FIELD_FETCH_STATE allows you to determine which fields should be retrieved. This attribute is used as follows:
Set_Attribute DF_FIELD_FETCH_STATE of iTable iColumn To True|False Get_Attribute DF_FIELD_FETCH_STATE of iTable iColumn To bFetchCol
Rather than passing a columns (field) number you can also pass the symbol DF_ALL_COLUMNS which operates on all columns, allowing you to select all or no columns for fetching in a single command.
Set_Attribute DF_FIELD_FETCH_STATE of iTable DF_ALL_COLUMNS ; To True|False
These commands allow you to do anything you want, but they do require that you execute these commands on a table by table (and column by column) basis. The cTableColumnFetchHelper class makes it a little bit easier to perform the most commonly required SCF operations on all open tables in your database. It performs two main functions.
1. Enable or Disable Selective Column Fetching for all Tables.
This allows you to toggle selective column fetching for all tables making it easy to create procedures where you can toggle between selective and full fetching modes.
2. Enable or Disable column fetching for all text fields in all tables.
The ability to disable the fetching of text columns is the most useful feature of this class. Most of the performance gains of selective column fetching occur when text fields are not fetched. This class provides an easy way to control text column fetching without you having to individually find the tables and columns you wish to mark. For example, a typical use of disabling text fields before a report might look like the
following:
Send DisableAllTextColumnFetching of oFetchHelper Send RunTheReport Send EnableAllColumnFetching of oFetchHelper
Note that the methods DisableAllTextColumnFetching and EnableAllColumnFetching may be the only two methods you will ever need to send.
Normally these operations are performed on all open files. An additional mode exists where these operations can be performed on a set of tables that you have specifically declared within the object. This would allow you to create multiple fetch helper objects that operate on different sets of tables.
If wish to operate on all open tables, which is how we expect you to use the class, you can create a single helper object based on this class and use it throughout your application.
// Top of program Use cTableColumnFetchHelper.pkg Object oFetchHelper is a cTableColumnFetchHelper End_Object // in any part of your application Send DisableAllTextColumnFetching of oFetchHelper Send RunTheReport Send EnableAllColumnFetching of oFetchHelper
If you use this class with databases that do not support selective column fetching, this class will do nothing - no error will be declared.
You must be careful that the columns that you choose not to select are really not needed. If you attempt to disable columns that are used within your application, you may receive a runtime error message. You will always receive an error if you attempt to move data into a non-fetching (inactive) column. You will receive an error if you attempt to move data from a non-fetching (inactive) column if the DRVR_REPORTACTIVECOLUMNERRORS attribute is set to true using the CLI_Set_Driver_Attribute command. We advise that you set this attribute to true so that you do not accidentally rely on column data in your application that does not exist.