Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Not an error, exactly. It depends on your close cursor option, and whether or not you try to reuse the cursor. Typically I do a SET OPTION near the start of my code, along the lines of:
/FREE
// SQL "H-spec"
Exec SQL SET OPTION CLOSQLCSR = *ENDMOD,
COMMIT = *NONE,
DATFMT = *ISO;
The other way is the CLOSQLCSR keyword on the CRTSQLRPGI command.
I should add that SQL cursor names are not local to a module; it's kind of, sort of, like a shared access path. I started including the module or procedure name as part of my cursor names, to ensure uniqueness. Of course, there may be times when you want to use the same cursor, but if you don't realize it's in play, it can be a real headache to debug.