{"record":{"id":"53c3d06c5d2fc13d","repo":"pentaho/pentaho-kettle","slug":"unable-to-prepare-combi-insert-statement-const-cr","errorCode":null,"errorMessage":"Unable to prepare combi insert statement :  + Const.CR + sqlStatement","messagePattern":"Unable to prepare combi insert statement :  \\+ Const\\.CR \\+ sqlStatement","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java","lineNumber":582,"sourceCode":"        }\n\n        sql += \" )\";\n\n        String sqlStatement = sql;\n        try {\n          debug = \"First: prepare statement\";\n          if ( isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys() ) {\n            logDetailed( \"SQL with return keys: \" + sqlStatement );\n            data.prepStatementInsert =\n              data.db.getConnection().prepareStatement(\n                databaseMeta.stripCR( sqlStatement ), Statement.RETURN_GENERATED_KEYS );\n          } else {\n            logDetailed( \"SQL without return keys: \" + sqlStatement );\n            data.prepStatementInsert =\n              data.db.getConnection().prepareStatement( databaseMeta.stripCR( sqlStatement ) );\n          }\n        } catch ( SQLException ex ) {\n          throw new KettleDatabaseException( \"Unable to prepare combi insert statement : \"\n            + Const.CR + sqlStatement, ex );\n        } catch ( Exception ex ) {\n          throw new KettleDatabaseException( \"Unable to prepare combi insert statement : \"\n            + Const.CR + sqlStatement, ex );\n        }\n      }\n\n      debug = \"Create new insert row rins\";\n      Object[] insertRow = new Object[ data.insertRowMeta.size() ];\n      int insertIndex = 0;\n\n      if ( !isAutoIncrement() ) {\n        insertRow[ insertIndex ] = val_key;\n        insertIndex++;\n      }\n      if ( meta.useHash() ) {\n        insertRow[ insertIndex ] = val_crc;\n        insertIndex++;","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java#L564-L600","documentation":"combiInsert builds the INSERT statement for a new junk-dimension row and prepares a JDBC PreparedStatement. SQLException (or any other exception) during preparation is wrapped into a KettleDatabaseException 'Unable to prepare combi insert statement : <sql>'.","triggerScenarios":"data.db.getConnection().prepareStatement(stripCR(sqlStatement)) throws in combiInsert (called from lookupValues) — invalid SQL, missing table/columns, insufficient INSERT privilege, or a closed connection.","commonSituations":"Junk dimension table absent (never created); DB user without INSERT grant; datatype mismatch in the generated SQL; connection broken mid-transformation.","solutions":["Read the cause SQLException and the embedded SQL statement; run it manually against the DB to see the real error","Create/verify the junk dimension table and required columns","Grant INSERT privileges to the connection's DB user","Reconnect the database (retest connection metadata) if the session was dropped"],"exampleFix":"-- before: table missing\n-- KettleDatabaseException: Unable to prepare combi insert statement\n-- after: create the junk dimension table first\nCREATE TABLE junk_dim (id BIGINT PRIMARY KEY, hashcode BIGINT, ...);","handlingStrategy":"retry","validationCode":"Database db = new Database(parent, databaseMeta);\ndb.connect();\nif (!db.checkTableExists(schemaTable)) {\n  throw new IllegalStateException(\"Junk dimension table missing before insert: \" + schemaTable);\n}\ndb.disconnect();","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n  trans.waitUntilFinished();\n} catch (KettleDatabaseException e) {\n  log.error(\"Combi insert prepare failed, SQL: \" + e.getMessage(), e);\n  // inspect cause for INSERT privilege or syntax errors before retrying\n}","preventionTips":["Ensure the DB user has INSERT grants on the junk dimension","Create the dimension table before the transformation runs","Log and review the generated SQL statement on failure"],"tags":["kettle","pdi","jdbc","sql","insert"],"backgroundTag":"sql-query-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"}