Re: Importing fixed-length ASCII data
Posted in 1992
> Shane Trammel <trammel@riogrande.cs.tcu.edu> writes:
> I need to import a fixed length ascii file into a database.
> My problem: I only want certain fields to be imported, not the
> whole thing. Can I selectively pick the fields I want.
> i.e f0 1-30 { name }
> f1 50-60 { address }
> f2 100-115 { company }
> Could someone please give me the proper systanx if it is
> possible to do what I am describibg.
Shane,
What you need to use is the dbload command. Below is a sample syntax:
FILE disptgrp.lod (fld1 6 - 8 ,
fld2 31 - 36,
fld3 48 - 49);
INSERT INTO trk_config (sitekey, trkgrp, sigtype, insttrk)
VALUES (656684, fld1, fld2, fld3);
Note: in the above example, the file name is not enclosed in quotes, although
the users manual specifies that it should be. This was an apparent bug in
our version of 4.0UG1 ISQL. The version that you are using by require the
quotation marks around the raw data file, in this case 'disptgrp.lod'.
These load commands are saved in a text file, I usually use the extension
'.cmd'. To run the the load the syntax is:
dbload -d database name -c command file -l error file -e # of errors
In the above, the -e parameter is used to specify the number of errors that
can be accepted before the load aborts. A further description of the dbload
command is in one of the appendices of the 4GL or SQL reference manuals.
-----------------------------------------------------------------------------
Bob Kane Internet: bob@worms-emh2.army.mil (IP 134.235.9.2)
TechDyn Systems Voice: (049) 6241-75936 (GERMANY)
CMR 421, BOX 706 Fax: (049) 6241-500154
APO AE 09056