MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Value of field declared in working-storage section

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Sun Aug 31, 2008 12:11 am    Post subject: Value of field declared in working-storage section Reply with quote

Hi,

Our DB2 program selects data from a production table into a record structure declared in working-storage section. There is one column that always has been returned '--' (nulls / blanks !!!). This particular column goes into a WS variable declared as below:

Code:

01  ws-efp-code x(02) value '**'.


Finally this record structure will be written to output file. If I look at output file it shows ** in that particular position!! I thought it should have been spaces because the column from table had returned '--' into ws-efp-code.

Any thoughts on this? Please explain.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Sun Aug 31, 2008 3:19 am    Post subject: Reply with quote

if a column is declared as nullable, the return from db2 will be nothing.....
the --- you see is a spufi or qmf respresentation of nulls since your sql did not bother to case or cast it otherwise.

if you want -- in a host variable when the return for the column is null, you need to code in your db2 program a check of the null indicator variable for that column in the sql for a value of -1 and when it is, MOVE '--' (or spaces or whatever) to WS-EFP-CODE.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Sun Aug 31, 2008 3:21 am    Post subject: Reply with quote

If the column is defined as nullable and you select a row with null for that column then the value of the host variable is not changed only the value of host null indicator is changed. That is why when selecting a nullable column you must always check the null indicator field. '--' is just spufi's way of showing that a column is null.
Back to top
View user's profile Send private message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Mon Sep 01, 2008 4:25 am    Post subject: Thanks for the reply. Reply with quote

Hi, dbzTHEdinosauer & CraigG,

Thanks for the details you have provided.

Because the ws-efp-code is null the output will always have the default value '**' which is declared with ws-efp-code. Am I right?
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Mon Sep 01, 2008 5:33 pm    Post subject: Re: Thanks for the reply. Reply with quote

mf_user wrote:
Hi, dbzTHEdinosauer & CraigG,

Thanks for the details you have provided.

Because the ws-efp-code is null the output will always have the default value '**' which is declared with ws-efp-code. Am I right?


It will contain what ever it contained before the select.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group