If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Using LOAD: How to load a literal as default?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-04, 05:20
magro magro is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 03-19-08, 04:21
Rizzotto Mario Rizzotto Mario is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 03-19-08, 05:53
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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:
Quote:
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
Reply With Quote
  #4 (permalink)  
Old 03-20-08, 08:13
dhallez dhallez is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 03-20-08, 08:27
dhallez dhallez is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
Obviously, the transient table contains additional columns defined with the WITH DEFAULT 'litteral' clause !
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On