Home page  
Help >
Import/Export Binary and Blocked Files
Version 7.11
Import/Export Binary and/or Blocked Files

Files which contain the Binary data types I, ID, F, or FD are pure data files, by which we mean that there is no carriage return and/or line feed at the end of each record.

A special case of pure data files are blocked files which may not contain binary data but which still have no end-of-record indicator. Blocked files tend to come from programs written for mainframes.

In either case these files contain fixed-length records, and the record length is known by the length of the Record Description that defines it.

The difference in handling is that when you issue a LOAD or UNLOAD command for binary files, you use a B option on the command (LOAD/B or UNLOAD/B).
Without the B option, you get garbage if the file contains binary data.

Suppose you have an Binary file on a floppy disk which contains 10,000 sales transactions for 1986. You want to LOAD that file into the SALES table in your database. The file name is 86SALES.DAT.

The Record Description to describe this file might be:

RD BDATA The name of the Record Description
store# x(3) is BDATA. There is no file type specified.
store_name x(12) The non-binary data is ASCII. The B option
mo x(2) on the LOAD will handle the total data
dy x(2) correctly. The data definition statements
yr x(4) consist of the field names, type, and
cust# x(6) sizes that comprise the typical record.
cust_name x(30) Note the Binary data types described in
street x(20) the RD. The records are fixed length.
city x(20)
state x(2)
zip x(5)
item# x(6)
descr x(20)
quan_bot ID
price FD

Lets look at the relationship between the RD in the Application Interface and the SALES table in the database:

RD BDATA TD SALES 50000 Records
store# x(3) store# x(3) key
store_name x(12) item# x(6) key
mo x(2) cust# x(6) key
dy x(2) pdate date key
yr x(4) :1 yr x(4) key
cust# x(6) :1 mo x(2) key
cust_name x(30) :1 dy x(2)
street x(20) descr x(20) key
city x(20) quan_bot n(4)
state x(2) price n(5.2)
zip x(5)
item# x(6)
descr x(20)
quan_bot ID
price FD

Now you are ready to load the 10,000 external records from the diskette in drive A. The LOAD command is

LOAD/B SALES BDATA a:\86SALES.DAT
(tablename) (rdname) (filename)

The Primary Rule For Data Transfer is
Where the names match, data moves. Differences in field size, type, and the order in which the fields appear are handled automatically when the data transfers. See Data Types and Rules for Data Transfer .

Consider what was left behind in our sample file transfer.

For any field in the RD where there is no corresponding field name in the database table, no data transfered. You can see several fields in the RD where data was left behind. The data base field named PDATE gets its value because data transferred into each of the elementary fields that it is composed of.

Export

An RD that includes Binary data can be used to LOAD/B or UNLOAD/B data. To UNLOAD/B the content of the SALES table to a diskette on drive A, issue the following commands:

FILL A SALES
UNLOAD/B A SALES EXPORT A:\SALES86.DAT

A file named SALES86.DAT is created on drive A. It is a pure data file which contains binary data. The RD, named EXPORT, might look like this:

RD EXPORT
store# x(3)
item# x(6)
cust# x(6)
mo x(2)
dy x(2)
yr x(4)
descr x(20)
quan_bot ID
price FD

All of the data in the SALES table "unloads," as there is a corresponding name in the RD for all of the fields in the SALES table. There is more detailed information available about data transfer. See Rules for Data Transfer .

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.