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 a DB2 table containing VARCHAR field

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


Joined: 20 May 2004
Posts: 97
Topics: 43
Location: hyderabad, India

PostPosted: Mon Apr 24, 2006 2:22 am    Post subject: Loading a DB2 table containing VARCHAR field Reply with quote

Hi all,

I had downloaded a DB2 table( which contains a VARCHAR field) into a flat file.

Lets say the field in DB2 table whihc is defined as VARCHAR is ADDRESS.
Lets say I unloaded a single record from the DB2 table & that record's value at ADDRESS field ( Datatype : VARCHAR ) is ' NEW JERSEY '.

I edited the unload file and changed value of ADDRESS field from 'NEW JERSEY ' to 'NEW ARK'.

My question is as we know that any insert in VARCHAR field thru COBOL requires populating the LENGTH field associated with the Field defined as VARCHAR.
Since here I changed the value of the ADDRESS field which is VARCHAR , do I need to change the length field associated with ADDRESS in unload file anywhere.
_________________
Priya Ranjan Mohanty
Consultant
Kanbay Software (I) pvt. Ltd.
Hyderabad
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Apr 24, 2006 5:11 am    Post subject: Reply with quote

Quote:

Since here I changed the value of the ADDRESS field which is VARCHAR , do I need to change the length field associated with ADDRESS in unload file anywhere.

pzmohanty,

When you unloaded the table , the unload utility puts the length in the first 2 bytes. Take a look at the SYSPUNCH dataset which will show you how the data is unloaded with their positions and length.

You can load without changing the length field but you will get wrong results if you are trying to validate the field based on the length of the column

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pzmohanty
Beginner


Joined: 20 May 2004
Posts: 97
Topics: 43
Location: hyderabad, India

PostPosted: Mon Apr 24, 2006 7:27 am    Post subject: Reply with quote

Hi Kolusu,

Thanks a lot for prompt reply.

I have couple of further questions.

a) Here is my SYSPUNCH content.
Code:
VER_DT                                 POSITION(     176         )   
DATE EXTERNAL(            10) ,                                     
CMNT_DESC                              POSITION(     186         )   
VARCHAR                                                             
     NULLIF(     442)='?'                                           
)                   


Here , in SYSPUNCH the VARCHAR field immediately follows the previous DB2 field and thus there is no different field shown for LENGTH , does that mean , the first 2 bytes of the VARCHAR field itself contains the length of the VARCHAR field.

b) If I do any INSERT in a DB2 table having VARCHAR field , I don't need to mention any length anywhere & DBMS itself takes care of the length , then why do we need to mention the length when we are loading a table.
_________________
Priya Ranjan Mohanty
Consultant
Kanbay Software (I) pvt. Ltd.
Hyderabad
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Apr 24, 2006 8:23 am    Post subject: Reply with quote

Quote:

does that mean , the first 2 bytes of the VARCHAR field itself contains the length of the VARCHAR field.


Pzmohanty,

Yes.

Quote:

b) If I do any INSERT in a DB2 table having VARCHAR field , I don't need to mention any length anywhere & [/b]DBMS itself takes care of the length[/b] , then why do we need to mention the length when we are loading a table.


Says who? Are you talking about Spufi when you said the length is automatically taken care of ? spufi takes cares of the length part automatically when inserting.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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