ysuryawanshi_mcs Warnings : 1 New User
Joined: 25 Mar 2006 Posts: 15 Location: pune(India)
|
|
|
|
Hi
I was trying to execute a COBOL-DB2 program where in I was executing an SQL statement:
SELECT EMPNO,EMPNAME,EMPSAL.EMPDEPT
INTO :RAD-EMPNO,:RAD-EMPNAME, :RAD-EMPSAL, :RAD-EMPDEPT
FROM EMPLOYEE_MASTER
WHERE DEPTNO = ?D001?
Where RAD-EMPNO,RAD-EMPNAME,RAD-EMPSAL and RAD-EMPDEPT are the DCLGEN variables. DEPTNO is the primary key.
The above SQL statement gives an error at Precompilation time that the column is not specified in the table specified.
The solution is that we need to give the dept value in double quotes and not in single quotes as shown below
SELECT EMPNO,EMPNAME,EMPSAL.EMPDEPT
INTO :RAD-EMPNO,:RAD-EMPNAME, :RAD-EMPSAL, :RAD-EMPDEPT
FROM EMPLOYEE_MASTER
WHERE DEPTNO = ?D001?
So now my query is that, is there any Precompiler option to accept single apostrophes? |
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
ysuryawanshi_mcs,
This does not answer your specific question, but how about moving the departmant # "D001" to a working storage area first.
Code: |
05 WS-DEPT PIC X(4).
MOVE 'D001' to WS-DEPT.
SELECT EMPNO,EMPNAME,EMPSAL.EMPDEPT
INTO :RAD-EMPNO,:RAD-EMPNAME, :RAD-EMPSAL, :RAD-EMPDEPT
FROM EMPLOYEE_MASTER
WHERE DEPTNO = :WS-DEPT
|
Dave |
|