Page 1 of 1

Error in FETCH for DB2 COBOL program

PostPosted: Tue Feb 03, 2009 3:48 pm
by sasicsv
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

Re: Error in FETCH for DB2 COBOL program

PostPosted: Wed Feb 04, 2009 12:34 am
by dick scherrer
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. . .

Re: Error in FETCH for DB2 COBOL program

PostPosted: Fri Feb 06, 2009 2:32 pm
by sasicsv
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

Re: Error in FETCH for DB2 COBOL program

PostPosted: Sat Feb 07, 2009 2:56 am
by dick scherrer
Hello,

Suggest you try changing ":hv-deptno," to ":dclgen-name.hv-deptno,".

Re: Error in FETCH for DB2 COBOL program

PostPosted: Mon Feb 09, 2009 3:40 pm
by sasicsv
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

Re: Error in FETCH for DB2 COBOL program

PostPosted: Tue Feb 10, 2009 12:54 am
by dick scherrer
You're welcome - good luck :)

d