how to find string is null



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

how to find string is null

Postby mohd dalib » Wed Jul 16, 2008 1:03 pm

hi
how to find that a string
strng pic x(10).
contains no char.


through finding length of the string we can find out that the string contains no character in it.i.e null string
but is there any other way to find it out? that sting variable contains no character.
mohd dalib
 
Posts: 6
Joined: Thu Jul 03, 2008 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to find string is null

 

Re: how to find string is null

Postby jayind » Wed Jul 16, 2008 2:02 pm

Hi mohd dalib,

In COBOL,
I hope you know the difference between a NULL and a SPACE.. Alphanumeric variables usually will have spaces but not nulls to my knowledge..Numeric variables can have nulls. Anyway, if you want to check for spaces you can check directly VAR = SPACES (HEX equivalent of a SPACE is X'40'), if you want to check for nulls "VAR = LOW-VALUES" (it is equivalent to null value having HEX value X'00').

Hope this helps...

Regards,
Jayind
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: how to find string is null

Postby dick scherrer » Thu Jul 17, 2008 1:00 am

Hello,

how to find that a string
strng pic x(10).
contains no char.
What you ask cannot really be done - every value from x'00' to x'FF' is "a char" and every PIC X byte will contain a value between x'00' and x'FF'.

There is no such thing as a NULL in a pic x field. You can test if some specific value(s) exist or do not exist.

If you clarify what you want to do, we can probably offer suggestions.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: how to find string is null

Postby ranga_subham » Fri Jul 18, 2008 7:52 pm

Dick, you say that there is no such thing as "NULLS" or "BLANKS". Is this pertaining to COBOL only :?:

I remember using the check such as variable = spaces or not !!

If so, why do we use NOT NULL while creating DB2 fields for tables :?

Thanks.
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

Re: how to find string is null

Postby dick scherrer » Fri Jul 18, 2008 8:15 pm

Hello,

Dick, you say that there is no such thing as "NULLS" or "BLANKS".
You just made a very wrong quantum leap. . . There probably should never be a thought that has "null" and "blank" together - they have nothing to do with each other. . . Simply said (again) - there is no such thing as a null in a pic x field.

If someone in your organization wants to call a space a null, that is just ignorant. They need to learn that a space (x'40') is not a null (which by definition has no value).

I remember using the check such as variable = spaces or not !!
Sure you do - we all do that. When we do that, we are not checking for null we are checking for some number of x'40's.

If so, why do we use NOT NULL while creating DB2 fields for tables
Some database management systems support the null concept - some do no. When you check for "null" or "not null" the comparison has nothing to do with spaces/blanks.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: how to find string is null

Postby ranga_subham » Fri Jul 18, 2008 8:28 pm

Thanks for explaining it.

Still some confusion bothers me. Let me try to put it in lines some time later.

Bye.
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

Re: how to find string is null

Postby dick scherrer » Fri Jul 18, 2008 10:01 pm

Hello,

You're welcome :)

Someone should be here when you organize/post what you want clarified.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post