IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to move null values to a field in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dkalyan_c

New User


Joined: 06 Apr 2006
Posts: 17

PostPosted: Fri Mar 09, 2012 6:09 pm
Reply with quote

Can some one tell me how to move null values to a field, which is defined as Nullable.


I want to do this in a Cobol program
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Mar 09, 2012 6:44 pm
Reply with quote

Quote:
Can some one tell me how to move null values to a field, which is defined as Nullable.
This cannot be done, period. There is no such thing as a "null value" on a mainframe (nor on a PC nor any other device). And this question has absolutely nothing to do with COBOL -- it is a general statement.

If you are referring to a DB2 (or other database) field that is defined to allow null values, that is handled in the data base by having an indicator variable. If the indicator variable is some specific value (-1 for example), then the data base field is considered to be NULL. However, note that neither the data base field nor the indicator variable actually have a "null value" in them -- the indicator variable has a value that by convention indicates the associated data base field is NULL while the actual data base field may have anything from X'00' to X'FF' (in COBOL terms, anything from LOW-VALUES to HIGH-VALUES). Byut the data base field WILL have some value, since by definition every byte has a value and cannot be "null value".
Back to top
View user's profile Send private message
dkalyan_c

New User


Joined: 06 Apr 2006
Posts: 17

PostPosted: Fri Mar 09, 2012 7:05 pm
Reply with quote

THANKS FOR THE RESPONSE.

My question here is the field has a default value of NULL and later updated to '01'. So, currently the field has a value '01' and i want to update it back to NULL thru a cobol program.

Is thr a way it can be done
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Mar 09, 2012 7:22 pm
Reply with quote

Yes - update the null indicator variable and update the table.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Mar 09, 2012 7:24 pm
Reply with quote

it is friday and you obviously do not want to refer to the manual,
but i am going to provide a link which you can read
(drop down towards the bottom a look at the syntax diagram and keywod explanations,
paying particular attention to the assignment clause)
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Mar 09, 2012 7:28 pm
Reply with quote

You did not reply if you are using a data base or not.

If you are using COBOL but not using a data base, then your statement
Quote:
the field has a default value of NULL
is ABSOLUTELY, CATEGORICALLY WRONG! That field has a value, period. Files and COBOL varaibles cannot, under ANY circumstances, have NULL values in them.

If you are using COBOL and using a data base, you need to find out from your data base documentation exactly how to set the value to NULL. For DB2, for example, there would be a pair of variables for the field -- the indicator varible (IIRC defined as PIC S9(04) COMP for DB2) and the data base variable. You would set the indicator variable to the appropriate value (-1 IIRC for DB2) and update the data base. The fact that the indicator variable is set to a paritcular value that means NULL indicates the value in the data base field would be ignored, no matter what it is.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Mar 09, 2012 8:12 pm
Reply with quote

And since it is Friday, that would explain why (unbelievably) no one has mentioned that if the user is talking about a database, he should say "column" instead of "field."

Time for the weekend for everyone!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Mar 10, 2012 1:45 am
Reply with quote

one of the reason for not remarking the field column whatsoever miswording
is that we all are getting fed up of repeating over and over the same thing
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Sat Mar 10, 2012 10:18 am
Reply with quote

I have been wondering just when this correction would finally poop out.

Looked like it would be aleph null.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top