View previous topic :: View next topic |
Author |
Message |
mf_user Intermediate

Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Sun Aug 31, 2008 12:11 am Post subject: Value of field declared in working-storage section |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Sun Aug 31, 2008 3:19 am Post subject: |
|
|
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 |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Sun Aug 31, 2008 3:21 am Post subject: |
|
|
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 |
|
 |
mf_user Intermediate

Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Mon Sep 01, 2008 4:25 am Post subject: Thanks for the reply. |
|
|
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 |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Mon Sep 01, 2008 5:33 pm Post subject: Re: Thanks for the reply. |
|
|
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 |
|
 |
|
|