Can host variable be a NULL in cobol DB2 program?

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
chinki
New Member
Posts: 2
Joined: Thu Dec 25, 2014 11:33 pm

Can host variable be a NULL in cobol DB2 program?

Post by chinki »

Hi,

Can a host variable be NULL? I understand that the DB2 column can be NULL but can a host variable of COBOL, can a host variable be NULL? Please help.
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: Can host variable be a NULL in cobol DB2 program?

Post by enrico-sorichetti »

a NULL column in db2 is a column that does not contain data
that' the reason that for NULLABLE columns two variables are needed
an INDICATOR variable to tell if the column contains a value and the variable to contain the value

since in IT every bit is significant a NULL content is pretty impossible to achieve ( in general )

a byte long variable can represent a number for 0 to 255 so every bit has a meaning

so to tell that the variable is NULL ( contains no info ) You will need another variable to tell so

remember... NULL is different from ZERO
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
chinki
New Member
Posts: 2
Joined: Thu Dec 25, 2014 11:33 pm

Re: Can host variable be a NULL in cobol DB2 program?

Post by chinki »

enrico-sorichetti wrote:a NULL column in db2 is a column that does not contain data
that' the reason that for NULLABLE columns two variables are needed
an INDICATOR variable to tell if the column contains a value and the variable to contain the value

since in IT every bit is significant a NULL content is pretty impossible to achieve ( in general )

a byte long variable can represent a number for 0 to 255 so every bit has a meaning

so to tell that the variable is NULL ( contains no info ) You will need another variable to tell so

remember... NULL is different from ZERO


Fine, thanks. So if a cobol variable has some value in it but the NULL indicator is indicating that it's NULL the host variable will be considered as NULL or as a variable with value? Please help.
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: Can host variable be a NULL in cobol DB2 program?

Post by enrico-sorichetti »

there is nothing automated .

in any system the content of a storage location is always a valid bit pattern.

it is up to You ( the application logic ) to determine if that content has a meaning for the application.

the DB2 convention relies on the indicator flag to tell if the column being retrieved contains any data ( it is NOT NULL )

You will have to test Yourself the indicator flag and process accordingly.

the question as posed int the topic title does not make any sense
because as already said every bit pattern is valid
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can host variable be a NULL in cobol DB2 program?

Post by Robert Sample »

So if a cobol variable has some value in it but the NULL indicator is indicating that it's NULL the host variable will be considered as NULL or as a variable with value?
The NULL indicator means that the value of the variable should be ignored as it is not valid data -- the variable is NULL. The variable will ALWAYS have some value in it; only by checking the NULL indicator can the programmer know if the value is valid or not.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”