MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LOADING TABLES HAVING IDENTITY COLUMNS

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Tue Dec 09, 2008 6:39 pm    Post subject: LOADING TABLES HAVING IDENTITY COLUMNS Reply with quote

Hi all,

Herein I am having a doubt while loading the data in the tables which have SEQ_NO as Identity column.
I am able to load the table, but, I have to synchronize the tables data in all test regions. while doing this, I am getting the seq no different.
For example, I am unloading the data from TEST1 region and loading in TEST2 region.
In the TEST1 region the values of SEQ_NO are somewhat like 1, 3, 4
when I am loading the data in TEST2 region the value are loading in it as 1, 2, 3

And, this does not make the tables in sync in the regions.

Please suggest me how to make them in sync.


DDL:
Code:

CREATE TABLE "NSH"."TBRAND"                             
  (  "BRAND_SEQ_NO"        DECIMAL (9, 0)      NOT NULL 
      GENERATED ALWAYS                                   
        AS IDENTITY                                     
        ( START WITH 1)                                 
    ,"BRAND_CD"            CHAR     (1)        NOT NULL 
    ,"CORP_BRAND_CD"       CHAR     (1)        NOT NULL 
    ,"BRAND_DESC"          CHAR     (50)       NOT NULL 
    ,"CRT_UID"             CHAR     (8)        NOT NULL 
    ,"CRT_TS"              TIMESTAMP           NOT NULL 
    ,"CRT_PGM_ID"          CHAR     (8)        NOT NULL 
    ,"UPDT_UID"            CHAR     (8)        NOT NULL 
    ,"UPDT_TS"             TIMESTAMP           NOT NULL 
    ,"UPDT_PGM_ID"         CHAR     (8)        NOT NULL 
  , PRIMARY KEY                                         
    ("BRAND_SEQ_NO"                                     
    ,"BRAND_CD"                                         
    )                                                   
  )                                                     
  IN "DBCDSA5"."TBRAND"                                 


Thanks all in advance
-Satyender
_________________
Satya
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Tue Dec 09, 2008 7:56 pm    Post subject: Reply with quote

Define the second TEST region as an Integer and unload TEST1 and load results in TEST2.

or set the identity column up something like this :
Code:

BRAND_SEQ_NO         INTEGER GENERATED BY DEFAULT AS IDENTITY
                  (START WITH 0          ,                 
                   INCREMENT BY 1        ,                 
                   CYCLE                 ,                 
                   MINVALUE -2147483648  ,                 
                   MAXVALUE  2147483647) ,               

and
Code:

SELECT MIN(BRAND_SEQ_NO)          FROM "NSH"."TBRAND; from TEST1
       SELECT MAXN(BRAND_SEQ_NO)         FROM "NSH"."TBRAND; from TEST1


ALTER TABLE "NSH"."TBRAND TEST2
ALTER BRAND_SEQ_NO RESTART WITH 1 ; 1= MIN(value) from above query

load table
ALTER TABLE "NSH"."TBRAND TEST2 ALTER BRAND_SEQ_NO RESTART WITH 2 ; 2= MAX(value) from above
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Dec 15, 2008 2:17 pm    Post subject: Reply with quote

Thanks a lot NASCAR9 for your suggestion.
_________________
Satya
Back to top
View user's profile Send private message
haatvedt
Beginner


Joined: 14 Nov 2003
Posts: 66
Topics: 0
Location: St Cloud, Minnesota USA

PostPosted: Fri Dec 26, 2008 9:03 pm    Post subject: Reply with quote

Satya,

you may want to check those values. I've always set the RESTART value to the max from select query + 1.

also you probably want to alter the identity column to be "GENERATE ALWAYS" as that was the original definition. This would need to be done after the table is loaded.

I had to alter the Load control cards generated during the unload as it generated a non-existent column name for the identity column. This may be dependent upon the particular software / version that I was using at the time.

good luck,
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group