ajayexpert
Programmer
I need to construct SELECT STATEMENT on the FLY and process the same in CURSOR.
I need something like the code below
**************************************************************************
MOVE 'SELECT EMPNO, LASTNAME FROM CORPDATA.EMPLOYEE WHERE EMPNO>?'
TO DSTRING.
EXEC SQL PREPARE S2 FROM STRING END-EXEC.
EXEC SQL DECLARE C2 CURSOR FOR S2 END-EXEC.
EXEC SQL OPEN C2 USING :EMP END-EXEC. PERFORM FETCH-ROW UNTIL SQLCODE NOT=0.
EXEC SQL CLOSE C2 END-EXEC.
STOP-RUN.
FETCH-ROW.
EXEC SQL
FETCH C2 INTO :EMP, :EMPNAME END-EXEC.
*************************************************************************
I was unable to execute the above code in DB2 Command Centre.
J
I need something like the code below
**************************************************************************
MOVE 'SELECT EMPNO, LASTNAME FROM CORPDATA.EMPLOYEE WHERE EMPNO>?'
TO DSTRING.
EXEC SQL PREPARE S2 FROM STRING END-EXEC.
EXEC SQL DECLARE C2 CURSOR FOR S2 END-EXEC.
EXEC SQL OPEN C2 USING :EMP END-EXEC. PERFORM FETCH-ROW UNTIL SQLCODE NOT=0.
EXEC SQL CLOSE C2 END-EXEC.
STOP-RUN.
FETCH-ROW.
EXEC SQL
FETCH C2 INTO :EMP, :EMPNAME END-EXEC.
*************************************************************************
I was unable to execute the above code in DB2 Command Centre.
J