Midrange News for the IBM i Community

Posted by: deepthi
Cursors in SQLRPGLE
has no ratings.
Published: 29 May 2012
Revised: 23 Jan 2013 - 2429 days ago
Last viewed on: 17 Sep 2019 (6610 views) 

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.

Cursors in SQLRPGLE Published by: deepthi on 29 May 2012 view comments(1)

Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Cursors in SQLRPGLE
Posted: 7 years 3 months 20 days 12 hours 31 minutes ago
Edited: Tue, 29 May, 2012 at 12:46:30 (2668 days ago)

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:

       // SQL "H-spec"
                           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.