HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide Printer User Manual


 
Data Load Utility: dbload
FairCom Corporation 4-7
statement. The following example shows the list interchanged with respect to the list in the
DEFINE RECORD statement.
DEFINE RECORD dept_rec AS
( dept_no, dept_name, location ) FIELD DELIMITER ' ' ;
FOR EACH RECORD dept_rec FROM dept_in
INSERT INTO ADMIN.department (loc, no, name)
VALUES (location, dept_no, dept_name) ;
NEXT RECORD
Here the items no, name, and loc are interchanged in both the table list and the values list when
compared with the DEFINE RECORD list.
The keyword NEXT RECORD must be specified after the FOR EACH statement so that the
insert loop is terminated.
4.6 EXAMPLES
This section gives different types of examples for dbload, both for variable length records as
well as fixed length records. The data files can either be ASCII or binary files. If they are
binary files they must be in the fixed length record format.
The following example is the commands file to load records into the dept table. The input data
file name is deptrecs_in which is an ASCII file in the variable length record format.
Example 4-1: Sample dbload commands files
DEFINE RECORD dept_rec AS
( dept_no, dept_name, location ) FIELD DELIMITER ' ' ;
FOR EACH RECORD dept_rec FROM deptrecs_in
INSERT INTO ADMIN.dept (no, name, loc)
VALUES (dept_no, dept_name, location) ;
NEXT RECORD
The following is the commands file to load records into the customer table. The input data file
is cust_in which is a binary file in the fixed length record format.
DEFINE RECORD cust_rec OF FIXED LENGTH 36
AS (
cust_no POSITION (1:4) LONG,
cust_name POSITION (5:15) CHAR,
cust_street POSITION (16:28) CHAR,
cust_city POSITION (29:34) CHAR,
cust_state POSITION (35:36) CHAR
) ;
FOR EACH RECORD cust_rec FROM cust_in
INSERT INTO ADMIN.customer (no, name, city, street, state)
VALUES (cust_no, cust_name, cust_city, cust_street, 'CA') ;
NEXT RECORD