×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

About cobol variable, please help

About cobol variable, please help

About cobol variable, please help

(OP)
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!

RE: About cobol variable, please help

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.

RE: About cobol variable, please help

And if the null indicator is set (i.e. the column is null), do NOT use the value in the other host variable. . .

RE: About cobol variable, please help

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...

RE: About cobol variable, please help

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.

RE: About cobol variable, please help

Presumably the colon acts like a space as it is not a valid character with a variable name.


Nic

RE: About cobol variable, please help

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....  

RE: About cobol variable, please help

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:

Quote:

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

Quote:

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


Nic

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close