SQLcode VS SQLstate lazarus / 16-Databases ---------------------------------------------------------------------- jormik · 2014-07-24 10:26 When I try to insert, by an elaborate procedure, in a Firebird table a longer string than the one I defined in the appropriate varchar(xxx) field of the database I obtain this error message: ---------------------------------------------------------------------- ----- -Dynamic SQL Error -SQL error code = -303 -arithmetic exception, numeric overflow, or string truncation -string rigth truncation ---------------------------------------------------------------------- ----- Moreover, Firebird 2.5.x has deprecated the SQL error codes (without yet eliminate them)  preferring the SQL compliant SQLSTATE code variables, but I have not found the corresponding value of SQLCODE number -303. I would intercept the problem in a Try...ecc. structure or (better) in a trigger procedure of the database to resolve it. Can anyone help me with a skeleton of the appropriate structure/trigger (better using SQLSTATE)? Thanks! ---------------------------------------------------------------------- BigChimp · 2014-07-24 13:31 Edit: It's probably a conversion to a signed integer while the original error code is unsigned. Nope sqlcode negative values are errors indeed... There is no support for sqlstate in the Firebird/Interbase driver. In your stored procedure / PL/SQL code in the database, you can catch errors with WHEN...ANY, see http://www.firebirdsql.org/refdocs/langrefupd25-sqlstate.html