Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Delivered
Workspace IBM i
Categories Db2 for i
Created by Guest
Created on Apr 17, 2020

Better error handling in embedded SQL

Currently, after every execution of an SQL statement, we must manually check the SQLSTATE to see if an error occurred. This adds bloat to our code. I would like to see the SQL engine send actual escape messages, so that we can catch these with RPG's error handling options (e.g. MONITOR).

I don't expect that this could become the default behaviour, so it would be nice if we could enable it through the SET OPTION syntax. Separate options for the behaviour of errors and warnings could be useful.

If that isn't possible, I wonder if you could extend the WHENEVER syntax (e.g. "WHENEVER SQLERROR GOTO host-label")? This seems like a good mechanism, but using a tag and GOTOs seems a bit antiquated in the modern procedure-based code we write. Could this somehow have an additional option to call a custom error-handling procedure?


Use Case:

Improving the error handling behaviour leads to cleaner embedded SQL code.

It is also more comprehensive: if one of our developers neglects to add SQLSTATE checking for a new statement, it ensures our code is not silently failing.


Idea priority High
  • Guest
    Reply
    |
    Dec 9, 2020

    IBM believes that the request described has been solved.

    The SQL WHENEVER statement was enhanced in fall 2020 with with IBM i 7.4 PTF Group level 10 and IBM i 7.3 PTF Group level 22. WHENEVER now supports calling a host language procedure, RPG subroutine, or COBOL procedure.

  • Guest
    Reply
    |
    Jul 20, 2020

    The CEAC has reviewed this requirement and recommends that IBM view this as a HIGH priority requirement that is important to address.

    This enhancement would help all developers (experienced and new to IBM i ) to code better programs.

    Background: The COMMON Europe Advisory Council (CEAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC has a crucial role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community and has therefore reviewed your RFE.

    To find out how CEAC help to shape the future of IBM i, see CEAC @ ibm.biz/BdYSYj and the article "The Five Hottest IBM i RFEs Of The Quarter" at ibm.biz/BdYSZT

    Therese Eaton – CEAC Program Manager, IBM

  • Guest
    Reply
    |
    Jul 20, 2020

    The CEAC has reviewed this requirement and recommends that IBM view this as a HIGH priority requirement that is important to address.

    This enhancement would help all developers (experienced and new to IBM i ) to code better programs.

    Probably no work-around, Broad appeal to SMB customers, High business value and marketing appeal  (including strategic, gap in the market)  

    Background: The COMMON Europe Advisory Council (CEAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC has a crucial role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community and has therefore reviewed your RFE.

    To find out how CEAC help to shape the future of IBM i, see CEAC @ ibm.biz/BdYSYj and the article "The Five Hottest IBM i RFEs Of The Quarter" at ibm.biz/BdYSZT

    Therese Eaton – CEAC Program Manager, IBM

  • Guest
    Reply
    |
    May 29, 2020

    IBM has received the requirement and is evaluating it. IBM will provide a response after evaluation is complete.

  • Guest
    Reply
    |
    Apr 22, 2020

    Due to processing by IBM, this request was reassigned to have the following updated attributes:
    Brand - Servers and Systems Software
    Product family - Power Systems
    Product - IBM i
    Component - Db2 for i
    Operating system - IBM i
    Source - None

    For recording keeping, the previous attributes were:
    Brand - Servers and Systems Software
    Product family - Power Systems
    Product - IBM i
    Component - Languages - RPG
    Operating system - IBM i
    Source - None

  • Guest
    Reply
    |
    Apr 21, 2020

    Dan - With respect, I disagree. We do have our own service program, as do many other shops, I'm sure. But why does everyone need their own version of something that IBM could very well offer as standard for a better product (IMO)?

    Take a simple cursor loop:

    exec sql OPEN cursor;
    exec sql FETCH FROM cursor INTO :ds;
    dow %subst(SQLSTATE : 1 :2) = '00';
    // do some stuff
    exec sql FETCH FROM cursor INTO :ds;
    enddo;
    exec sql CLOSE cursor;

    Then add error checking (I'll admit you would get away without checking the close of cursor, but I'll add it for completeness):

    exec sql OPEN cursor;
    checkSqlState();
    exec sql FETCH FROM cursor INTO :ds;
    checkSqlState();
    dow %subst(SQLSTATE : 1 :2) = '00';
    // do some stuff
    exec sql FETCH FROM cursor INTO :ds;
    checkSqlState();
    enddo;
    exec sql CLOSE cursor;
    checkSqlState();

    Checking each individual SQL statement is very pessimistic and interrupts the flow of the actual business logic. I would like to be able to deal with exceptions as exactly that: exceptional behaviour. Having escape messages would allow me to surround multiple statements in a MONITOR block (for example) with a single error handler, instead of padding out the code as shown.


    Barbara - I did see that. It's actually what motivated me to request this, since it has been on my mind for a while :)

  • Guest
    Reply
    |
    Apr 20, 2020

    Regarding the need to use a TAG opcode for the WHENEVER clause, there's an upcoming enhancement to support defining a tag using an EXEC SQL statement. It will be available around the time of the spring 2020 TRs for 7.3 and 7.4.

    EXEC SQL TAG HANDLER;

    https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rbafztag.htm

    See https://www.ibm.com/support/pages/node/1381917

  • Guest
    Reply
    |
    Apr 19, 2020

    This change request is not needed. Just write a sub-proc in a utility service program that you call after each embedded command. One line call, no bloat. This new sub-proc will turn on/off pre-defined booleans (in a protocol copybook) and if the error is unknown report it to a log table. This is how we do it. There is no need for an escape message. If you find your code is bloated, you are not doing it right.