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 > generated column with load

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-10, 08:45
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
generated column with load

Getting very confused:

db2 v9.5 on win2003

I've created a table with a generated column based upon another NOT NULL column.
the new generated column is part of 1 or more indexes
the new table is populated by means of a load
I'm on a time-critical path, so I would not like time-consuming "set integrity's" after the load has finished

simplyfied example:
Code:
create table nw 
 ( nw_id int not null
 , nw_ts timestamp not null
 , nw_gen  int generated always as ((year(nw_ts) * 100) + month(nw_ts))
 );
create index xx on table nw (nw_id asc , nw_gen asc);
declare x1 cursor for select a , b from another_table;
load from x1 of cursor modified by ???? insert into nw;
So I concider:
- load with "modified by generatedmissing"
- load with "modified by generatedignore"
- load with "modified by generatedoverride"

I cannot work out what is the best option for me to use. It could be my bad google-skills, or my bad english or my limited intelligence or the "set integrity" can never by avoided.

Who knows the best syntax to use in this case?
Reply With Quote
  #2 (permalink)  
Old 09-09-10, 10:19
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Reply With Quote
  #3 (permalink)  
Old 09-09-10, 12:26
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
See if I understand:
Code:
load with "modified by generatedoverride"
SET INTEGRITY FOR  nw GENERATED COLUMN IMMEDIATE UNCHECKED
The "set integrity" will not take long to process and the table is ready for use and the index is properly built. Correct?
Reply With Quote
  #4 (permalink)  
Old 09-09-10, 12:59
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Why do you need to override the generated column values? I would let LOAD do the job by specifying "generatedmissing".
Reply With Quote
  #5 (permalink)  
Old 09-09-10, 13:30
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Quote:
Originally Posted by n_i View Post
Why do you need to override the generated column values? I would let LOAD do the job by specifying "generatedmissing".
That was my iniital idea, but then the table was left in "integrity pending state" and was trying to avoid that.
Can I use the "generated missing" in combination with "inmediate unchecked"?
This area is the most "blurry part of db2" to me.
Reply With Quote
  #6 (permalink)  
Old 09-10-10, 09:48
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Does not work
The
Code:
set integrity for ... check immediate unchecked
does not take away the
Code:
SQL0668N  Operation not allowed for reason code "1" on table 
...  SQLSTATE=57016
ERGO: "set integrity for ... immediate checked" can NOT be avoided
Reply With Quote
  #7 (permalink)  
Old 09-10-10, 14:03
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
How about specifying column names explicitly?

Code:
load from x1 of cursor METHOD P(1 , 2) insert into nw(nw_id , nw_ts);
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