DECLARE CURSOR
From SQL PL Guide for DB2
DECLARE CURSOR statement
The DECLARE CURSOR statement have to be used to define a cursor which you're using in your code (for more details have a look to the CURSOR describtion).
The option WITH RETURN TO CALLER/CLIENT is necessary to return the result set back to a calling stored procedure or application.
Syntax:
DECLARE <cursorname> CURSOR [WITH HOLD] [WITH RETURN TO CALLER|CLIENT] FOR <sql-statement>;
Example:
create procedure myproc ()
result sets 1
begin
declare mycur cursor with return to client for
select firstnme concat ' ' concat midinit concat ' ' concat lastname
from employee;
open mycur;
end!