File View Generation

Individual records of datastore files are held as BLOBs. This is primarily for performance when inserting, updating, and retrieving records using COBOL file I/O. However, this does mean that the data in the records is not readily visible when attempting to view it using regular SQL SELECT statements (for example, when using a database management tool such as PostgreSQL's pgadmin or Oracle's SQL Developer).

The File View Generator (dbfhview) creates database views to make the viewing of your datastore data possible. Once a generated view is installed in your database, you can use all of the usual SQL tools and commands to manipulate the view of the data in table form.

The database views are based on file definitions contained within a structure files that was generated using the Data File Editor. Each field in a file definition is represented by a column in a view. Each column maps on to bytes at a given offset in the underlying BLOB and is represented with a database data type corresponding to the field's COBOL data type as defined in the structure file (that is, the view coerces the underlying BLOB bytes into the database data type represented by each column in the view).

Structure files can often contain more than one FD, and so you can use dbfhview to list the available FD structures, and then select the appropriate one for your database view.

Instead of installing the view directly into your database, you can generate a script file, which you can run manually to install the view. This gives you an opportunity to customize the view (for example, to remove columns) before it is installed in the database.

With the exception of Db2, the generated views use T-SQL functions that are installed in the associated datastores. For Db2, you must install some external functions instead to provide the equivalent functionality. External functions, equivalent to the T-SQL versions of the same name, can also be installed for SQL Server and PostgreSQL. You would typically only need to do this if the supplied T-SQL functions were not providing the desired performance. See Installing Database Server Functions for more information.