How to handle DB2 null in COBOL?



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

How to handle DB2 null in COBOL?

Postby Balr14 » Thu Dec 09, 2010 10:29 pm

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?
Balr14
 
Posts: 38
Joined: Fri Oct 01, 2010 9:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to handle DB2 null in COBOL?

 

Re: How to handle DB2 null in COBOL?

Postby enrico-sorichetti » Thu Dec 09, 2010 10:40 pm

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!
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
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: How to handle DB2 null in COBOL?

Postby Balr14 » Thu Dec 09, 2010 10:58 pm

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."
Balr14
 
Posts: 38
Joined: Fri Oct 01, 2010 9:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to handle DB2 null in COBOL?

Postby GuyC » Wed Dec 22, 2010 3:18 pm

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.
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post