This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2 Replies Last post: Feb 5, 2010 9:21 AM by David Birmingham  
myettam   4 posts since
Nov 20, 2009
Currently Being Moderated

Feb 5, 2010 9:03 AM

Loading Fixed width flat file to table using NZLOAD

I have to load the data from Fixed width flatfile to Table using NZLOAD.

Can any one can help me to get the syntax for nzload with fixed width.

Shawn Fox   392 posts since
Aug 15, 2006
Currently Being Moderated
1. Feb 5, 2010 9:23 AM in response to: myettam
Re: Loading Fixed width flat file to table using NZLOAD

NPS 4.6.5 and 4.6.6 are the only versions which currently support fixed format loading.  Are you on one of these versions?  TwinFin systems (NPS 5.0) do not currently support fixed width input files for nzload, so you have to load the entire line into a single column in a staging table and then use substr to pull out the individual fields.

 

The next release of TwinFin (I'm guessing version NPS 5.1 although I've heard rumors it may have a version other than 5.1) will support fixed format files.

 

A simple example of loading a fixed format file:

 

NZLOAD

 

create table foo (x integer, y varchar(20), z integer, dt date);

nzload -t foo -format 'fixed' -layout 'bytes 5, bytes 20, bytes 8, bytes 10' -df /tmp/fixed.dat

This loads 4 fields out of the file, field one is 5 bytes wide, field 2 is 20 bytes, etc

 

EXTERNAL TABLE

 

select *
from external 'c:\temp\fixed.dat'
(
   x integer,
   y varchar(20),
   z integer,
   dt date
)
using
(
   remotesource 'odbc'
   format 'fixed'
   layout(
           bytes 5,
           bytes 20,
           bytes 8,
           bytes 10
   )
);

You can do much more complex formats than just simple fixed width.  nzload also handles variable width fields where the field width is in the file right before the column.  For example a line might look like "0812345678" where the first 2 characters '08' tell nzload how wide the next field is (8 characters).

 

David Birmingham   159 posts since
Sep 24, 2007
Currently Being Moderated
2. Feb 5, 2010 9:24 AM in response to: myettam
Re: Loading Fixed width flat file to table using NZLOAD

<snip>

More Like This

  • Retrieving data ...