View previous topic :: View next topic
|
Author |
Message |
padma_prakasam
New User
Joined: 06 Oct 2005 Posts: 31
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
srinut123
New User
Joined: 11 Oct 2005 Posts: 62 Location: India
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
Sarva_bubli
New User
Joined: 09 Aug 2006 Posts: 37 Location: Pune, India
|
|
|
|
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 |
|
|
|