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 

Equivalent structure in cobol flat file for varchar in db2

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Sat Nov 06, 2004 8:30 am    Post subject: Equivalent structure in cobol flat file for varchar in db2 Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Sat Nov 06, 2004 9:23 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Mon Nov 08, 2004 7:11 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Nov 08, 2004 9:29 am    Post subject: Reply with quote

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
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 -> Application Programming 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