As Matt mentioned the problem occurs because of the max. size of open cursors is reached using the query method (several "dummy" result sets/cursors were opened but not closed). In a "normal" way the result set of a query is processed and the result set is closed (using the close() method of the result set object) which closes the cursor and reduces the number of open cursors. The parameter "HOLD_CURSOR" says that a cursor is left open over DB LUWs (e.g. a commit closes a cursor, setting the parameter to true, avoids that).
But long story, short answer: The EXECUTE_QUERY method used above is wrong in that context, because no query is executed, but a DDL statement. Therefore the creation of that temporary tables has to be done using method EXECUTE_DDL of the statement object. That avoids the problem in advance.
Regards,
Florian