Db2

 View Only
Expand all | Collapse all

DB2 Error Handling and verboseness of error messages for users in applications

  • 1.  DB2 Error Handling and verboseness of error messages for users in applications

    Posted Fri November 17, 2023 04:06 PM

    Hi everyone! A team I am helping is developing an application in node.js where on the back end we call SQL queries from node.js that execute inserts and update statements against tables. The issue we are having is if an insert or update statement has a field with data too long for a defined column, we just get back an SQL error code/state saying:

    "[Error: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001]"

    which on IBMs docs for db2 has this translation for the 22001 state:

    22001 Character data, right truncation occurred; for example, an update or insert value is a string that is too long for the column, or a datetime value cannot be assigned to a variable, because it is too small.

    Our goal is to output to the user on the front end that they attempted to enter data that is too long, wrong type, etc, and for which column(s). Does anyone have DB2 or node.js application development experience wisdom to share here? We do have an idea how to solve this ourselves but figured it is worth asking what exists first as it seems something should!



    ------------------------------
    Jeffrey Willoughby
    ------------------------------


  • 2.  RE: DB2 Error Handling and verboseness of error messages for users in applications

    IBM Champion
    Posted Sun November 19, 2023 04:41 PM
    Edited by Jan Nelken Sun November 19, 2023 04:41 PM

    Hi!
    The data specified through SQLSetParam or SQLBindParameter is larger than the maximum size allowed for the corresponding use of a parameter marker.

    You could DESCRIBE table in question - to establish your SQL limits for all columns and check that length of the input parameter does not exceed that.



    ------------------------------
    Jan Nelken
    ------------------------------