View previous topic :: View next topic |
Author |
Message |
pzmohanty Beginner
Joined: 20 May 2004 Posts: 97 Topics: 43 Location: hyderabad, India
|
Posted: Mon Apr 24, 2006 2:22 am Post subject: Loading a DB2 table containing VARCHAR field |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Apr 24, 2006 5:11 am Post subject: |
|
|
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 |
|
|
pzmohanty Beginner
Joined: 20 May 2004 Posts: 97 Topics: 43 Location: hyderabad, India
|
Posted: Mon Apr 24, 2006 7:27 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Apr 24, 2006 8:23 am Post subject: |
|
|
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 |
|
|
|
|