I'm trying to improve upon error handling in a Java/Postgres application and an error that occurs frequently is input being too long for a column with a fixed length. I roll the transaction back when this occurs, but before the rollback is done I'm trying to find a way determine which column is violating length constraints to make debugging this error a lot easier and more efficient.
My approach is to:
- Query
informationschema.columns
to get all column names of the length displayed in the error message - Query each column returned in step 1 to check length constraints
However, when i attempt to query the information schema I get this error:
ERROR: current transaction is aborted, commands ignored until end of transaction block
Is there a way to still run queries from java on this transaction, or is there a better way to go about retrieving the columns violating their length constraints?