View previous topic :: View next topic
|
Author |
Message |
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
bamohan
New User
Joined: 29 Jan 2007 Posts: 33 Location: chennai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
rockish
Active User
Joined: 05 Jun 2009 Posts: 185 Location: Planet Earth
|
|
|
|
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 |
|
|
|