Skip navigation
12095 Views 2 Replies Latest reply: Feb 5, 2010 9:24 AM by David Birmingham RSS
myettam New Enzee 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 Enzee Exraordinaire 1,333 posts since
    Aug 15, 2006

    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 Active Enzee 426 posts since
    Sep 24, 2007

    <snip>

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points