{"record":{"id":"58e6f588dd712ca5","repo":"pentaho/pentaho-kettle","slug":"error-inserting-row-into-table-tablename-with-values","errorCode":null,"errorMessage":"Error inserting row into table [tableName] with values: rowValues","messagePattern":"Error inserting row into table \\[tableName\\] with values: rowValues","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java","lineNumber":381,"sourceCode":"        errorMessage = dbe.toString();\n      } else {\n        if ( meta.ignoreErrors() ) {\n          if ( data.warnings < 20 ) {\n            if ( log.isBasic() ) {\n              logBasic( \"WARNING: Couldn't insert row into table: \"\n                + rowMeta.getString( r ) + Const.CR + dbe.getMessage() );\n            }\n          } else if ( data.warnings == 20 ) {\n            if ( log.isBasic() ) {\n              logBasic( \"FINAL WARNING (no more then 20 displayed): Couldn't insert row into table: \"\n                + rowMeta.getString( r ) + Const.CR + dbe.getMessage() );\n            }\n          }\n          data.warnings++;\n        } else {\n          setErrors( getErrors() + 1 );\n          data.db.rollback();\n          throw new KettleException( \"Error inserting row into table [\"\n            + tableName + \"] with values: \" + rowMeta.getString( r ), dbe );\n        }\n      }\n    }\n\n    // We need to add a key\n    if ( generatedKey != null ) {\n      outputRowData = RowDataUtil.addValueData( outputRowData, rowMeta.size(), generatedKey );\n    }\n\n    if ( data.batchMode ) {\n      if ( sendToErrorRow ) {\n        if ( batchProblem ) {\n          data.batchBuffer.add( outputRowData );\n          outputRowData = null;\n\n          processBatchException( errorMessage, updateCounts, exceptionsList );\n        } else {","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java#L363-L399","documentation":"A non-batch single-row insert failed with a KettleDatabaseException; when error handling is not configured for the step, the transaction is rolled back (data.db.rollback()) and a KettleException naming the target table and the offending row values is thrown. It is the per-row insert failure report for table output.","triggerScenarios":"data.db.insertRow (or equivalent) throws KettleDatabaseException, the step warns-count is not exceeded, getStepMeta().isDoingErrorHandling() is false, so rollback() runs and the KettleException with tableName + rowValues is thrown from writeToTable.","commonSituations":"Constraint violations on individual rows; value too long for column; wrong data types vs table schema; NULL in NOT NULL column; table schema changed since transformation was designed.","solutions":["Read the row values in the message to find the offending field, then fix the data upstream.","Compare the input row schema against the target table schema (types, lengths, nullability).","Enable error handling on the step and connect the error hop to route bad rows instead of failing the transformation.","Verify the table definition is current (someone may have altered constraints)."],"exampleFix":"// before: inserting 200-char string into VARCHAR(100)\n// after: add a truncate/mapping step upstream or ALTER TABLE target MODIFY col VARCHAR(255)","handlingStrategy":"try-catch","validationCode":"// Validate a row against the table schema before insert\nfor ( int i = 0; i < rowMeta.size(); i++ ) {\n  ValueMetaInterface vm = rowMeta.getValueMeta( i );\n  if ( r[i] == null && !isNullable( tableSchema, vm.getName() ) ) {\n    throw new IllegalArgumentException( \"NOT NULL violation on \" + vm.getName() );\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  writeToTable( row );\n} catch ( KettleException e ) {\n  if ( e.getMessage().startsWith( \"Error inserting row into table\" ) ) {\n    log.error( e.getMessage() ); // includes table name + offending row values\n    // route row to error handling or fix data\n  }\n}","preventionTips":["Enable error handling + error hop so bad rows are captured instead of failing the run","Re-verify table schema after DB migrations/ALTERs","Truncate/convert values to match column lengths and types upstream"],"tags":["kettle","table-output","insert-failed","database","rollback"],"backgroundTag":"database-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}