Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Unanswered: Using LOAD: How to load a literal as default?

    Hi!

    I have an environment with DB2 for z/OS, Version 7.1.

    I have unloaded a table with DSNUPROC. The new table to be loaded with the data has basically the same structure but with some additional columns.

    The new columns shall be loaded with a default value, not necessarily with the DB2 default for the corresponding format but with a literal.

    Searching the DB2 Utility Guide and Reference documentation I have found the NULLIF- and DEFAULTIF-settings:

    (FIELD1 POSITION(*) CHAR(4)
    FIELD2 POSITION(*) CHAR(3) NULLIF(FIELD1='SKIP')
    FIELD3 POSITION(*) CHAR(5))

    respectively

    (FIELD1 POSITION(*) CHAR(4)
    FIELD2 POSITION(*) CHAR(3) DEFAULTIF(FIELD1='SKIP')
    FIELD3 POSITION(*) CHAR(5))

    In that case FIELD2 would be intialized with SPACE since that is the DEFAULT for CHARACTER, correct?

    But what I really want for example is to initialize FIELD2 uncondititonally always with the literal 'ABC' (which is not in the Load-File because FIELD2 did not exist in the unloaded table!).

    Is it possible to initialize the new fields directly during the LOAD with specific literals as a default value? If so what is the correct syntax?

    I already know that an update of all the new columns after the load with the standard DEFAULT using DEFAULTIF and a condition that is always true could be used as an ugly workaround, but that is not what I really want.

    Thanks a lot for your support in advance!

    Mathew

  2. #2
    Join Date
    Mar 2008
    Posts
    1

    Using LOAD: How to load a literal as default?

    No answers to this question? I have a similar problem. Thank you

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    If you have a look at the "INTO-table-spec" for the LOAD utility (http://publib.boulder.ibm.com/infoce...ax__intotable), you will find in the "field specification" the following clause:
    DEFAULTIF--field selection criterion
    You may want to check whether this option is available for your version as well.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Jun 2004
    Posts
    3
    LOAD into a transient table using DEFAULTIF to enforce such default values. Then UNLOAD from transient to LOAD into the real destination table.

  5. #5
    Join Date
    Jun 2004
    Posts
    3
    Obviously, the transient table contains additional columns defined with the WITH DEFAULT 'litteral' clause !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •