Previous Topic: Unload Database Level Information

Next Topic: Build a Format for Reading Data

Obtain and Unload Field Level Information

To unload and reload the data, you need to know the names of the fields you are unloading, and their attributes. Use &NDBINFO NUMBER= to extract field level information. This information (record type 10) will be written, and vartable built for use when processing data records.

To allow the reload program to easily perform field-level deletion, and so on, you should also write the relative field number as well as the field name when you unload.

Before reading the field information, set up parameters for the sequence that you will define later, defaulting it to RID. If you encounter a sequence key definition, alter the sequence parameter to FIELD=fieldname.

At the end of the field definitions, write a record type 11 to indicate the end:

&VARTABLE ALLOC ID=FTAB KEYFMT=NUM DATA=1
&SEQBY = RID
&FNUM = 0
&DOUNTIL &FNUM EQ &NDBDBNFLDS
   &FNUM = &FNUM + 1
   &NDBINFO &DBNAME NUMBER=&FNUM
   &VARTABLE ADD ID=FTAB KEY=FNUM FIELDS=DATA  +
         VARS=NDBFLDNAME
   &IF &NDBFLDKEY = SEQUENCE &THEN &SEQBY =    +
         FIELD=&NDBFLDNAME
   &FILE ADD 10 &FNUM +
      &NDBFLDNAME&NDBFLDFMT&NDBFLDKEY   +
      &NDBFLDNULLF&NDBFLDNULLV&NDBFLDUPD   +
      &NDBFLDCAPS&NDBFLDMAXL&NDBFLDDESC   +
      &NDBFLDUSER1&NDBFLDUSER2&NDBFLDUSER3 +
      &NDBFLDUSER4
   &LOOPCTL 1000
&DOEND
&FILE ADD 11