Prev | Advanced Operations Guide | Next |
Importing and Exporting Data
This section provides detailed information on importing and exporting data using the following BUTIL commands: COPY, LOAD, RECOVER, and SAVE.
COPY
The COPY command copies the contents of one MicroKernel file to another. COPY retrieves each record in the input data file and inserts it into the output data file. The record size must be the same in both files. After copying the records, COPY displays the total number of records inserted into the new data file.
Note
COPY performs in a single step the same function as a RECOVER command followed by a LOAD command.
Using the COPY command, you can create a data file that contains data from an old file, but has new key characteristics.
To copy a MicroKernel data file
- Use the CREATE command to create an empty data file with the desired key characteristics (key position, key length, or duplicate key values).
Use CLONE to create an empty data file using the characteristics of an existing file.
- Use the COPY command to copy the contents of the existing data file into the newly created data file.
Format
BUTIL -COPY sourceFile outputFile [/O< owner1 | *> [/O<owner2 | *>]] [/S]Example
The following command copies the records in COURSE.MKD to NEWCRS.MKD. The COURSE.MKD input file does not require an owner name, but the NEWCRS.MKD output file uses the owner name Pam.
butil -copy course.mkd newcrs.mkd /O /OPamIf you omit the first /O from this example, the utility assumes that the owner name Pam belongs to the input data file, not the output data file.
LOAD
The LOAD command inserts records from an input ASCII file into a file. The input ASCII file can be a single file or an extended file (the base file plus several extension files). LOAD performs no conversion on the data in the input ASCII file. After the utility transfers the records to the data file, it displays the total number of records loaded.
Note
The LOAD command opens the output file in Accelerated mode; during a LOAD operation, the MicroKernel does not log the file. If you are using archival logging, back up your data files again after using the LOAD command.
Extended files: If the utility finds the next extension file, it continues the load process. Do not delete any extension file created earlier by the SAVE and RECOVER commands. If the file has three extensions and the user deletes the second one, LOAD stops loading records after processing the first extension file.
If SAVE or RECOVER created three extension files and a fourth one exists from a previous SAVE or RECOVER, LOAD reads the records from the fourth extension and inserts them into the MicroKernel file. If a fourth file exists, then you need to delete it before starting the LOAD process.
Before running the LOAD command, you must create the input ASCII file and the data file. You can create the input ASCII file using a standard text editor or an application; the input ASCII file must have the required file format (as explained in Importing Records From an ASCII File ). You can create the data file using either the CREATE or the CLONE command.
Format
BUTIL -LOAD unformattedFile outputFile [/O<owner |*>] [/S]Example
The following example loads sequential records from the COURSE.TXT file into the COURSE.MKD file. The owner name of the COURSE.MKD file is Sandy.
butil -load course.txt course.mkd /OSandyRECOVER
The RECOVER command extracts data from a MicroKernel file and places it in an ASCII file that has the same format as the input ASCII file that the LOAD command uses. This is often useful for extracting some or all of the data from a damaged MicroKernel file. The RECOVER command may be able to retrieve many, if not all, of the file's records. You can then use the LOAD command to insert the recovered records into a new, undamaged MicroKernel file.
Note
The Maintenance utility performs no conversion on the data in the records. Therefore, if you use a text editor to modify an output file containing binary data, be aware that some text editors may change the binary data, causing the results to be unpredictable.
Format
BUTIL -RECOVER sourceFile unformattedFile [/O<owner |*>] [/S] [/Q] [/J] [/I]For each record in the source file, if the RECOVER command receives a variable page error (Status Code 54), it places all the data it can obtain from the current record in the unformatted file and continues the recovery process.
The utility produces the following messages:
- informs you about the name of the last extension file created
- checks if the next extension file exists, and if so, tells you to delete it
- if you move the extended unformatted files to a different location, you are prompted to move the base file and all of its extension files
Example
The following example extracts records from the COURSE.MKD file and writes them into the COURSE.TXT file.
butil -recover course.mkd course.txtSAVE
The SAVE command retrieves records from a MicroKernel file using a specified index path and places them in an ASCII file that is compatible with the required format for the LOAD command. You can then edit the ASCII file and use the LOAD command to store the edited data in another data file. (See Importing Records From an ASCII File for more information about the ASCII file format.)
SAVE generates a single record in the output ASCII file for each record in the input data file. Upon completion, SAVE displays the total number of records saved.
Note
The Maintenance utility performs no conversion on the data in the records. Therefore, if you use a text editor to modify an output file containing binary data, be aware that some text editors may change the binary data, causing the results to be unpredictable.
Format
BUTIL -SAVE sourceFile unformattedFile [Y indexFile | N <keyNumber | -1>] [/O<owner1 | *> [/O<owner2 | *>]] [/S] [/Q] [/J] [/I]
The utility produces the following messages:
- informs you about the name of the last extension file created
- checks if the next extension file exists, and if so, tells you to delete it
- if you move the extended unformatted files to a different location, you are prompted to move the base file and all of its extension files
Examples
The following two examples illustrate how to use the SAVE command to retrieve records from a data file.
This example uses a NEWCRS.IDX external index file to retrieve records from the COURSE.MKD file and store them in an unformatted text file called COURSE.TXT:
butil save course.mkd course.txt newcrs.idxThe following example retrieves records from the COURSE.MKD file using key number 3 and stores them in an unformatted text file called COURSE.TXT:
butil -save course.mkd course.txt n 3
Prev Btrieve Command-Line Maintenance Utility (BUTIL) |
Contents Up Check for Revisions | Next Creating and Modifying Data Files |