Error in FETCH for DB2 COBOL program



IBM's flagship relational database management system

Error in FETCH for DB2 COBOL program

Postby sasicsv » Tue Feb 03, 2009 3:48 pm

hai to every one,
i have a proble in db2 cobol program regarding fetching data from multiple table through Cursor for Select

I have 2 table with DEPTNO on both tables
I genarated host variables through DCLGEN

table description is
EMP DEPT
---- ---------
EMPNO DEPTNO
NAME DEPTDES
DEPTNO


when writing code in cobol

exec sql
DECLARE cur1 CURSOR FOR
select empno,
name,
deptno,
deptdes
from emp e,
dept d
where e.deptnp=d.deptno
end-exec

Here there is no problem

In Below code there is a problem
In FETCH it is showing Ambiquety in hv:deptno

exec sql
fetch cur1
into :hv-empno,
:hv-name,
:hv-deptno,
:hv-deptdes
end-exec.


plz help me
sasicsv
 
Posts: 3
Joined: Tue Feb 03, 2009 3:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Error in FETCH for DB2 COBOL program

 

Re: Error in FETCH for DB2 COBOL program

Postby dick scherrer » Wed Feb 04, 2009 12:34 am

Hello and welcome to the forum,

In FETCH it is showing Ambiquety in hv:deptno
The name is not unique. One of the names will have to be changed to some other name or the name will have to be qualified in the code.

Suggest using unique names. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Error in FETCH for DB2 COBOL program

Postby sasicsv » Fri Feb 06, 2009 2:32 pm

Thank u for u r reply

can i ask a question

In cobol we have qualifiers to distinguish if two groups have same name elemntary data name in
the same manner can we distinguish the host variables in fetch statement.

can u plz send the revelent code to do this problem.

i will be very greatful to u
thanks again and byee
sasicsv
 
Posts: 3
Joined: Tue Feb 03, 2009 3:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Error in FETCH for DB2 COBOL program

Postby dick scherrer » Sat Feb 07, 2009 2:56 am

Hello,

Suggest you try changing ":hv-deptno," to ":dclgen-name.hv-deptno,".
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Error in FETCH for DB2 COBOL program

Postby sasicsv » Mon Feb 09, 2009 3:40 pm

thank d. sch
i will try that one and if any problem i will send that related messages
and i think we will discuss and get a solution for that one

thanks again and bye
sasicsv
 
Posts: 3
Joined: Tue Feb 03, 2009 3:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Error in FETCH for DB2 COBOL program

Postby dick scherrer » Tue Feb 10, 2009 12:54 am

You're welcome - good luck :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post