IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Significance of level 49 with DB2 VARCHAR


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Fri Sep 17, 2010 1:46 pm
Reply with quote

Hi.

Please let me know what's the difference between below two types of COBOL equivalent for DB2 VARCHAR data types.

Why we need to declare level 49 always for DB2 VARCHAR data type.

(I have referred some of the past posts, but it doesn't have absolute answer)


01 WS-NAME-IN
05 WS-NAME-LEN PIC S(04) COMP
05 WS-NAME PIC X(25)


01 WS-NAME-IN
49 WS-NAME-LEN PIC S(04) COMP
49 WS-NAME PIC X(25)


Thanks
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Sep 17, 2010 2:30 pm
Reply with quote

because IBM said so:
Application Programming and SQL Guide wrote:
The number 49 has a special meaning to DB2. Do not specify another number
Back to top
View user's profile Send private message
bamohan

New User


Joined: 29 Jan 2007
Posts: 33
Location: chennai

PostPosted: Fri Sep 17, 2010 2:56 pm
Reply with quote

Because 49 is the maximum level beyond which variables cannot be subgrouped.

In VARCHAR, bytes will be occupied based on the Char text. If there is 05 or 10 under a varchar group variable any 15 level variable defined under it will tend to join along with the group which is Invalid.

That is why 49 is used as subgroup in VARCHAR
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Sep 17, 2010 3:26 pm
Reply with quote

bamohan wrote:
Because 49 is the maximum level beyond which variables cannot be subgrouped.

In VARCHAR, bytes will be occupied based on the Char text. If there is 05 or 10 under a varchar group variable any 15 level variable defined under it will tend to join along with the group which is Invalid.

That is why 49 is used as subgroup in VARCHAR



Did you wash your pants after saying this?
what i mean it the above is total BullShit.
do not persist in wasting peoples time with your inaccurate garbage.
Back to top
View user's profile Send private message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Fri Sep 17, 2010 4:46 pm
Reply with quote

Mohan,

bamohan wrote:
it will tend to join along with the group which is Invalid.


It is not necessary that 05 or 10 under 01 level, I can put multiple 49 levels under 01 level, then according to you following statement is valid?

01 WS-NAME-IN
49 WS-NAME-LEN PIC S(04) COMP
49 WS-NAME-FIRST PIC X(10)
49 WS-NAME-MID PIC X(10)
49 WS-NAME-LAST PIC X(05)
49 FILLER PIC X(100)
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Fri Sep 17, 2010 11:42 pm
Reply with quote

As IBM quotes,
Group data items in the declare section can have any of the valid host variable types described as subordinate data items. This includes all numeric and character types, as well as all large object types. You can nest group data items up to 10 levels. Note that you must declare VARCHAR character types with the subordinate items at level 49. If they are not at level 49, the VARCHAR is treated as a group data item with two subordinates, and is subject to the rules of declaring and using group data items.
Code:
    01 staff-record.
        05 staff-id       pic s9(4) comp-5.
        05 staff-name.
            49 l          pic s9(4) comp-5.
            49 d          pic x(9).
        05 staff-info.
            10 staff-dept pic s9(4) comp-5.
            10 staff-job  pic x(5).

In the example above, staff-info is a group data item, whereas staff-name is a VARCHAR. The same principle applies to LONG VARCHAR, VARGRAPHIC, and LONG VARGRAPHIC. You may declare group data items at any level between 02 and 49
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to load to DB2 with column level ... DB2 6
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
No new posts JPM Reports for each DB2 V12 Function... DB2 0
No new posts Program level statistics CICS 6
No new posts Feild level validation to test first ... JCL & VSAM 10
Search our Forums:

Back to Top