Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About cobol variable, please help 1

Status
Not open for further replies.

nguyenminhphuong

Technical User
Feb 22, 2011
1
VN
Hi everyone!
I have the following FETCH statement that I don't understand:
1 EXEC SQL FETCH CURKOTHRTABNKET INTO
2 :HSTHYOSYU,
3 :HSTTWAYMX,
4 :HSTTRG,
5 :HSTORGCAR,
6 :HSTDSTCAR,
7 :HSTPASCAR001,
8 :HSTPASCAR002,
9 :HSTPASCAR003,
10 :HSTCLS,
11 :HSTARANAM,
12 :HSTABNUNTSUU:HSKABNUNTSUU,
13 :HSTABNMINSUU:HSKABNMINSUU
14 END-EXEC.

In lines 12 and 13, it fetchs only one value into 2 variable. It's strange for me. Can anyone please explain me the code? Sorry if my question is silly.

Thanks in advance!
 
Any table value that can be NULL usually requires what is called an indicator variable. This is the second value in lines 12 and 13. Test these values to determine whether the value is NULL.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
And if the null indicator is set (i.e. the column is null), do NOT use the value in the other host variable. . .
 
the indicator is a seperate field.

Code:
           06  DB2-NULL-INDICATOR          PIC S9(4) COMP-5.
               88  DB2-IS-NULL             VALUE -1.
               88  DB2-IS-NOT-NUMERIC      VALUE -2.
               88  DB2-IS-OK               VALUE ZERO.

I expected a space between the two variables on line 12 and 13...
 
Why was a space expected?

It may help if we can see the cobol definitios for this table (or this part of it if this is a table with lots of columns.
 
Presumably the colon acts like a space as it is not a valid character with a variable name.


Nic
 
a host variable HAS to have the ":" or it is not considered a variable. and indicator variables are placed immediately after the corresponding variable without any field separator

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Alle the people i know, use a space.... Every example in any manual has a space... that's all, i never saw it without any space..... So that is why i am a bit blinking....
 
I have just referenced an old Rexx/DB2 program of mine and it abuts the null indicator variable to the host variable - e.g. :hostvar:hvnul. The manual also uses this method when discussing null indicators:
EXEC SQL
SELECT PHONENO
INTO :CBLPHONE:INDNULL
FROM DSN8710.EMP
WHERE EMPNO = :EMPID
END-EXEC.

but also gives this alternative form (which is not mentioned in the Rexx section so may not be appropriate

EXEC SQL
SELECT PHONENO
INTO :CBLPHONE INDICATOR :INDNULL
FROM DSN8710.EMP
WHERE EMPNO = :EMPID
END-EXEC.


Nic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top