Is it just me, or are you really expecting sqlstate '02000' (sqlcode +100) on the Open cursor -
rather than the first fetch?
If you want something other than sqlcode +466 to be returned, you could try setting the
procedure's return sqlstate to '01Hxx' - and get sqlcode +462.
The only way I could think of getting sqlcode +100 in the calling program (with a null result
set) would be to return a dynamic result set - and the first fetch in the caller would get +100.
James Campbell
On 26 Jan 2023 at 20:37, Phillip Victor via International DB2 User wrote:
> Hey Renu,
> Below is a basic outline of my code
> Declares
> Declare cursor
> Declare Exit handler for sqlstate '02000'
> Declare Exit handler for sqlexception
> Open Cursor
> It's still returning a zero and not a +100. I also tried it with the "handler for not found". I have code set up for each handler to move the sqlcode to the output.
>
> Thanks
>
> ------------------------------
> Phillip
> ------------------------------
> -------------------------------------------
> Original Message:
> Sent: Jan 26, 2023 02:46 PM
> From: Renu Sharma
> Subject: DB2 SQL PL SP Handling a Not Found
>
> Hi PhillipPlease do the Sql error code checking after you get the result and put your logic for rows not found. I.e 100. You have to declare handler and cursor to process the data. Please go to IBM site and look for cursors in SQL Procedures
> Thanks
> Renu Sharma
>
>
> Sent from the all new AOL app for iOS