Multiple choice technology databases

A Simple stored procedure is created with Dynamic Result sets 3 However only 2 cursors with return to client are defined within the source code. What will happen when you call the SP ?

  1. Will executes successfully

  2. Fails as limit is 3 but only 2 opened

  3. Executes with warning

  4. Would not allow compiling the SP at the first place

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When DYNAMIC RESULT SETS is set to 3 but only 2 cursors are defined, the procedure executes successfully. The DYNAMIC RESULT SETS clause declares the maximum number of result sets that can be returned, and having fewer cursors than the maximum is perfectly valid.

AI explanation

DYNAMIC RESULT SETS in a DB2 stored procedure declares the maximum number of result sets that may be returned to the caller, not a mandatory exact count. Since the procedure only opens 2 cursors with 'return to client' out of a declared maximum of 3, it is fully within the allowed limit and will execute successfully — there's no requirement to use every declared result set. It would only fail if more cursors were left open than the declared maximum.