Page 1 of 1

How to handle DB2 null in COBOL?

PostPosted: Thu Dec 09, 2010 10:29 pm
by Balr14
If a DB2 field is defined as nullable and is set to null, the conventional way of representing this in COBOL is low-values (x'00'). However, that won't work with binary fields (COMP). Is there another way to represent nulls for binary fields, other than defining a null indicator? My experience is you don't allow DB2 fields to be declared as nullable when they may contain binary data. Any other thoughts?

Re: How to handle DB2 null in COBOL?

PostPosted: Thu Dec 09, 2010 10:40 pm
by enrico-sorichetti
My experience is you don't allow DB2 fields to be declared as nullable when they may contain binary data. Any other thoughts?

since for NULLABLE columns DB2 ( and friends ) rely ONLY on the NULL indicator
it' up to the application requirements to declare columns as NULLABLE regardless of the CONTENT!

Re: How to handle DB2 null in COBOL?

PostPosted: Thu Dec 09, 2010 10:58 pm
by Balr14
Here's what one DB2 DBA said: "Unless a null value is significant to an application binary zeros is acceptable for an empty binary field. Personally I do not design table columns to allow nulls. Handling nulls requires additional program logic that can slow things down and db2 has to do more work to service your request."

Re: How to handle DB2 null in COBOL?

PostPosted: Wed Dec 22, 2010 3:18 pm
by GuyC
Unless a null value is significant to an application
Duh, of course you don't design databases that are not significant to the application. Nullable columns slowdown DB2 less than varchars.
Actually NULL allows DB2 to do less work, especially in case of R.I.

the conventional way of representing a nullable column set to NULL in COBOL is low-values (x'00').

Maybe standard practice is some environments, but defenitely not a convention.