The following syntax declares the cursor that allows procedures to return table values as result sets. Declaring a cursor allows them to be used by the function or procedure; however, they are not part of the response until they are executed in an OPEN statement.
Note: There can be fewer OPEN statements in a procedure than stated by the DYNAMIC RESULTS SETS clause, but there cannot be more.
DECLARE cursor_name CURSOR WITH RETURN FOR <select_statement>

where:

cursor_name
specifies the name of the cursor that you are declaring.
select_statement
specifies the SELECT statement of which the cursor holds the results.