View previous topic :: View next topic |
Author |
Message |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Sat Nov 06, 2004 8:30 am Post subject: Equivalent structure in cobol flat file for varchar in db2 |
|
|
Hi,
I have a field in db2 table with varchar(50) and i have a file in which record structure for eg. is like below
01 Pty-det.
05 Name
49 len pic s9(4) comp-3
49 text pic x(50).
05 city pic x(30).
when i download the table how will be the data in the file? My understanding is, in the record city will start from 51 loc irrespective of the number of characters in name. is it correct? while loading the file to table should we move the size of the variable to len field in name or the exact number of characters in the text filed. sould we start city from 51 position or after the length of the text+1?
thanks in advance.
nadh |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sat Nov 06, 2004 9:23 am Post subject: |
|
|
Nadh,
Please search before posting. This has been discussed earlier. check this link
http://www.mvsforums.com/helpboards/viewtopic.php?t=244&highlight=varchar
Please read it completely.
Quote: |
when i download the table how will be the data in the file? My understanding is, in the record city will start from 51 loc irrespective of the number of characters in name. is it correct?
|
No your understanding is wrong. When you unload the data , CITY will start will in position 53 (50 + 2 bytes of length for NAME column) assuming that NAME column is defined as NOT null. If it is defined as NULL then your city will start in position 53.
Btw the length will be defined as COMP and not a comp-3 item as you have shown.
The length field will be S9(04) COMP which occupies 2 bytes.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Mon Nov 08, 2004 7:11 am Post subject: |
|
|
Thank you Kolusu.
I have one doubt. Is it must to declare corresponding variables for varchar in cobol with 49 level number. I got the same result if i declared with level number 10 alo. then what is the significance of 49 level number.
Pls. clarify my doubt. I searched for it, but i did not find the one.
Thanks in advance.
nadh |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Nov 08, 2004 9:29 am Post subject: |
|
|
Nadh,
IBM used the 49 levels to distinguish a varchar/vargraphic columns. Just by looking at the definitions generated from the DCLGEN , we can easily find out the VARCHAR/VARGRAPHIC fields.
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|