Using UNLOAD/INPUT
 
     Unload/Input_you have probably heard this term used many times, 
     particularly from Microrim Technical Support. Just what does 
     Unload/Input mean and how does it work? 
     
     The term Unload/Input refers to a series of R:BASE commands that 
     allow you to: 
     
     Transfer tables, forms, reports, and labels from one database to 
     another.
     
     Correct certain database errors identified through AUTOCHK. 
     Correct unexplained database problems that can arise, and are not 
     identified through AUTOCHK.
     
     Recover disk space and restructure the database.
     
     The set of commands used in an Unload/Input process are:
     UNLOAD, INPUT, and OUTPUT.
 
     The UNLOAD Command
     The UNLOAD command writes the data and/or structure of a table or 
     database to an ASCII text file that you designate through the OUTPUT 
     command. The UNLOAD command generates an ASCII file of R:BASE commands 
     and data. The R:BASE commands recreate the table or database 
     structure. The unload file contains CREATE TABLE commands, for 
     example, to recreate tables, and LOAD commands to load the data back 
     into the tables. The data is always written in ASCII delimited format. 
     You can look at an unload file using any ASCII text editor.
 
     In R:BASE versions 5.0 and above, unloading data from a table with a 
     BLOB data type produces two files: the unload file named in the OUTPUT 
     command, and a file with the same name but with the extension .LOB. 
     The .LOB file contains the BLOB data. The output file contains a 
     reference to the .LOB file. Never make modifications to this .LOB 
     file, however. Both files must be located in the same drive and 
     directory before issuing the INPUT command.
 
     The INPUT Command
     The INPUT command executes the R:BASE commands written to the unload 
     file by the OUTPUT command. The INPUT command restores the unload file 
     to the current database or creates a new database.
 
     The OUTPUT command
     The OUTPUT command opens a file to hold the R:BASE commands and data 
     generated by the UNLOAD command. The file is commonly called the 
     "unload file" or the "output file". When the UNLOAD command is 
     completed, the OUTPUT SCREEN command is used to close the file. The 
     OUTPUT command places the file in the current drive and directory 
     unless otherwise specified.
 
     The commands are generally used in the following sequence: 
     
     OUTPUT filename
     UNLOAD ALL
     OUTPUT SCREEN
     INPUT filename
     
     Depending on the result you want, the syntax will vary. Use the 
     following examples as a guide: 
     
     Transfer a Table From One Database to Another 
     This example transfers the table customer from the CONCOMP database to 
     another database called SAMPLE. Two unload files are created: 
     tables.str contains the structure of the table to transfer, and 
     tables.dat contains the data. The first step is to create the unload 
     files:
 
     CONN Concomp
     SET NULL -0-
     OUTPUT tables.str
     UNLOAD STRUCTURE FOR Customer
     OUTPUT SCREEN
     OUTPUT tables.dat
     UNLOAD DATA FOR Customer
     OUTPUT SCREEN
     
     The file tables.str must be edited to change the existing database 
     name from CONCOMP to the new database name SAMPLE. 
     
     RBEdit Tables.str
     
     Locate the statement "CREATE SCHEMA AUTHOR Concomp". Change Concomp 
     to sample. Save the changes and exit RBEdit. Now you are ready to put 
     the table into the new database. First, create the table structure in 
     the new database by inputting the file tables.str, then load the data
 
 
     CONN Sample 
     INPUT tables.str
     INPUT tables.dat
 
     In this example, the table structure and data were unloaded to 
     separate files, making it easy to edit and change the table structure 
     information. The structure file, tables.str, is a small file; the data 
     file, tables.dat, can be quite large. When unloading the structure of 
     a table or a database, the unload file always references the database
     name.
 
     Transfer a Report, Form, or Label From One Database to Another
     This example demonstrates transferring a report from the CONCOMP 
     database to the SAMPLE database. The report to be transferred is named 
     customer. An unload file called tables.dat is created to store the 
     data of the report.
 
     The UNLOAD command in this example references the system table 
     SYS_REPORTS2. If you are transferring a form, reference the table 
     SYS_FORMS2. A label transfer would reference the SYS_LABELS2 table. 
     This example is specific to version 5.0 and above. If you are 
     transferring from a previous version of R:BASE, the UNLOAD command 
     references the SYS_REPORTS, SYS_FORMS, or SYS_LABELS system table 
     instead.
 
     CONN Concomp
     SET NULL -0-
     OUTPUT tables.dat
     UNLOAD DATA FROM SYS_REPORTS2 +
     WHERE SYS_REPORT_NAME = 'Customer'
     OUTPUT SCREEN
     CONN Sample
     INPUT tables.dat
     
     Because only data was transferred, not structure, only one unload file 
     was used and the file did not need to be edited. When transferring 
     forms, reports, and labels between databases, make sure the new 
     database does not already have a form, report, or label with the same 
     name as the one being transferred.
 
     Correct Database Problems or Restructure the Database This example 
     unloads the entire structure and data from the CONCOMP database. After 
     the UNLOAD command, the original CONCOMP database is renamed to 
     SAMPLE. The INPUT command recreates the CONCOMP database from the 
     commands in the unload file. The unload file, tables.all, contains 
     both the database structure and data from all the tables.
 
     CONN Concomp
     SET NULL -0-
     OUTPUT tables.all
     UNLOAD ALL
     OUTPUT SCREEN
     DISCO
     RENAME Concomp.rb* Sample.rb*
     INPUT tables.all
     
     For more information on the UNLOAD, INPUT, and OUTPUT commands, refer 
     to on line Help and the R:BASE 5.0 Reference Manual.