{"record":{"id":"4bf0269519fc814d","repo":"pentaho/pentaho-kettle","slug":"unable-to-save-job-entry-of-type-sql-to-the-repository-for","errorCode":null,"errorMessage":"Unable to save job entry of type 'sql' to the repository for idJob=","messagePattern":"Unable to save job entry of type 'sql' to the repository for idJob=","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java","lineNumber":183,"sourceCode":"      throw new KettleException( \"Unable to load job entry of type 'sql' from the repository with idJobentry=\"\n        + idJobentry, dbe );\n    }\n  }\n\n  // Save the attributes of this job entry\n  //\n  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId idJob ) throws KettleException {\n    try {\n      rep.saveDatabaseMetaJobEntryAttribute( idJob, getObjectId(), CONNECTION_TAG, ID_DATABASE, databaseMeta );\n\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQL_TAG, sql );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), USE_VARIABLE_SUBSTITUTION_TAG, useVariableSubstitution\n        ? \"T\" : \"F\" );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFROMFILE_TAG, sqlFromFile ? \"T\" : \"F\" );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFILENAME_TAG, sqlFilename );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SEND_ONE_STATEMENT_TAG, sendOneStatement ? \"T\" : \"F\" );\n    } catch ( KettleDatabaseException dbe ) {\n      throw new KettleException(\n        \"Unable to save job entry of type 'sql' to the repository for idJob=\" + idJob, dbe );\n    }\n  }\n\n  public void setSQL( String sql ) {\n    this.sql = sql;\n  }\n\n  public String getSQL() {\n    return sql;\n  }\n\n  public String getSQLFilename() {\n    return sqlFilename;\n  }\n\n  public void setSQLFilename( String sqlFilename ) {\n    this.sqlFilename = sqlFilename;","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java#L165-L201","documentation":"KettleException thrown by JobEntrySQL.saveRep when saving the 'sql' job entry's attributes (useVariableSubstitution, sqlFromFile, sqlFilename, sendOneStatement, plus SQL and connection) to the repository fails with a KettleDatabaseException. The message carries idJob to locate the failing job.","triggerScenarios":"Calling saveRep for a 'sql' job entry when any saveJobEntryAttribute call raises KettleDatabaseException: repository write failure, constraint violation, connection loss, or read-only database.","commonSituations":"Repository session expired mid-save; DB in read-only mode; schema version mismatch; very large SQL text exceeding column size limits in R_JOBENTRY_ATTRIBUTE.","solutions":["Inspect the wrapped KettleDatabaseException cause for the actual SQL error.","Confirm the repository database is writable and the session is still valid.","Check value size limits (e.g. large SQL against VALUE_NUM/VALUE_STR column sizes).","Upgrade the repository schema to match the current Pentaho version and retry."],"exampleFix":"// before\nsqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);\n// after\ntry {\n  sqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);\n} catch (KettleException e) {\n  logError(\"Could not save SQL entry for job \" + idJob + \": \" + e.getCause(), e);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (rep == null || idJob == null) throw new IllegalArgumentException(\"Repository and idJob are required\");\n// ensure entry has an ObjectId before saving attributes\nif (sqlEntry.getObjectId() == null) throw new KettleException(\"Entry must be persisted before saveRep\");\n","typeGuard":null,"tryCatchPattern":"try {\n  sqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);\n} catch (KettleException e) {\n  logError(\"Save failed for idJob=\" + idJob + \" cause=\" + e.getCause(), e);\n  throw e; // fail the overall job save\n}","preventionTips":["Keep SQL text within repository column size limits","Save jobs over a stable repository connection","Upgrade repository schema after Pentaho upgrades"],"tags":["repository","pdi","job-entry","database"],"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"}