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.
I'm am working on my first RPG stored procedure thanks to Chris Ringer :-) and I have a situation where I want to check for a couple of conditions before allowing the cursor to open and return the result set. Well, if those conditions aren't met I want to bypass the processing.
Since I'm passing the return of the result set I'm getting an SQLSTATE of 38501, stating that there was a problem with the program.
Is there a way of handling this? Thanks for any input.
Chris
I think I need to add something to the stored procedure to bypass the error if returned, but I'm not sure what. Thanks, all!
So, you're saying you want to return with no result set, which is not the same as a result set with no rows?
There are a couple things you could try. See SQL Programming, there's a section in Routines, Stored Procedures, Returning a completion status to the calling program.
Extra parameter sounds easy, but feels like extra overhead, since you should be testing SQLSTATE anyway.
Thanks for the input, Dale. What I thought of was, if the counter for number of status = '0' records comes back zero, set the parameter for the select of the status to some bogus value (I used 'X'). It wouldn't find any, so it returned a blank result set. This seemed to work great and obviously was very simple.
I will check out your suggestion, because I'm sure I'll run into other cases where it might be a better solution. Thanks again!
Chris