Page 1 of 1

Can host variable be a NULL in cobol DB2 program?

Posted: Fri Jan 08, 2016 2:20 pm
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.

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

Posted: Fri Jan 08, 2016 2:56 pm
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

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

Posted: Mon Jan 11, 2016 1:55 pm
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.

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

Posted: Mon Jan 11, 2016 4:59 pm
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

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

Posted: Mon Jan 11, 2016 6:12 pm
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.