Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Using the column name as the Host variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
padma_prakasam

New User


Joined: 06 Oct 2005
Posts: 31

PostPosted: Fri Dec 15, 2006 8:02 am    Post subject: Using the column name as the Host variable
Reply with quote

Hi,

I have cobol-Db2 program which has a select query that fetches values into host variables. Example i fetch EMPNAME into host variable WS-EMPNAME and want to move to another variable. I can use WS-EMPNAME to move. But is it possible to use EMPNAME itself (the coulmn name not host variable) in any MOVE statements?

Thanks
Padma
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Dec 15, 2006 10:24 am    Post subject:
Reply with quote

Hi Padma,

I am not able to fully understand ur query but it look like

Code:
FETCH CURSOR_1
   INTO :WS-EMPNAME


then u want to move which is correct
Code:

MOVE WS-EMPNAME TO WS-OTHERVARIABLE


but u cant use
Code:
MOVE EMPNAME TO WS-OTHERVARIABLE
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Dec 15, 2006 10:45 am    Post subject: Re: Regarding Host variables
Reply with quote

Padma...

Host variables are nothing more than a COBOL Field declaration to map with a DB2 table field. They may have a similar nominclature as field name.
Thats why we put a colon ":" while using host variable in the SQL queries, so it is easy for compiler to understand which one of these is a host variable.
So you should be able to use something like this.
Code:
EXEC SQL
   SELECT EMPID INTO :EMPID
   FROM EMPLOYEES WHERE SALARY >= 1000000
END-EXEC.

MOVE EMPID TO WS-OTHER-VARIABLE

Ekta... Pls correct, if wrong... wanted to check it before, but couldn't.
Back to top
View user's profile Send private message
srinut123

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Fri Dec 15, 2006 10:45 am    Post subject:
Reply with quote

Hi Padma

The visibility of EMPNAME outside of the END-EXEC will be lost.. so u cant use the column name outside of the Embedded SQL statement. That is the reason we store the data from the query in a Host variable and will use this where ever we want in the program

Steve
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Dec 15, 2006 11:37 am    Post subject:
Reply with quote

Hi There,

Just one more addition to whatever Priyesh said. In the following query
EMPID should be declare in working storage section if DCLGEN is not declare in the program otherwise EMPID which is the coloum of table ( Should be in dclgen). but if we are taking EMPID as working storage variable not the variable which is present in DCLGEN that better to use qualifier.Hope it make some sense

Code:
EXEC SQL
   SELECT EMPID INTO :EMPID
   FROM EMPLOYEES WHERE SALARY >= 1000000
END-EXEC.

MOVE EMPID TO WS-OTHER-VARIABLE
Back to top
View user's profile Send private message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Fri Dec 15, 2006 3:52 pm    Post subject:
Reply with quote

Hi,
EXEC SQL
SELECT EMPSAL
INTO :WS-EMPSAL
FROM EMP_TABLE
WHERE EMPNO = XXXXXX
END-EXEC


In the above u can
MOVE WS-EMPSAL TO WS-VARIABLE-SAL

Correct me if I'm wrong
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 17 Thu Jul 13, 2017 2:11 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us