Ok, here it is
I need define a cursor having select statement with dynamic where clause.
Please let me know if the query is not clear.
I belive what I am asking is not the Rocket Science.
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.