{"record":{"id":"b6775a4218ac067f","repo":"pentaho/pentaho-kettle","slug":"unable-to-obtain-last-logdate-from-table-logtable","errorCode":null,"errorMessage":"Unable to obtain last logdate from table \" + logtable","messagePattern":"Unable to obtain last logdate from table \" \\+ logtable","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":3933,"sourceCode":"    sql += \" AND    \" + databaseMeta.quoteField( \"STATUS\" ) + \"    = 'end'\";\n    sql += \" AND    \" + jobtrans + \" = ?\";\n    sql +=\n      \" ORDER BY \"\n        + databaseMeta.quoteField( \"LOGDATE\" ) + \" DESC, \" + databaseMeta.quoteField( \"ENDDATE\" ) + \" DESC\";\n\n    try {\n      pstmt = connection.prepareStatement( databaseMeta.stripCR( sql ) );\n\n      RowMetaInterface r = new RowMeta();\n      r.addValueMeta( new ValueMetaString( \"TRANSNAME\", 255, -1 ) );\n      setValues( r, new Object[] { name } );\n\n      try ( ResultSet res = pstmt.executeQuery() ) {\n        rowMeta = getRowInfo( res.getMetaData(), false, false );\n        row = getRow( res );\n      }\n    } catch ( SQLException ex ) {\n      throw new KettleDatabaseException( \"Unable to obtain last logdate from table \" + logtable, ex );\n    }\n\n    return row;\n  }\n\n  public synchronized Long getNextValue( Hashtable<String, Counter> counters, String tableName, String valKey )\n    throws KettleDatabaseException {\n    return getNextValue( counters, null, tableName, valKey );\n  }\n\n  public synchronized Long getNextValue( Hashtable<String, Counter> counters, String schemaName, String tableName,\n                                         String valKey ) throws KettleDatabaseException {\n    Long nextValue = null;\n\n    String schemaTable = databaseMeta.getQuotedSchemaTableCombination( schemaName, tableName );\n\n    String lookup = schemaTable + \".\" + databaseMeta.quoteField( valKey );\n","sourceCodeStart":3915,"sourceCodeEnd":3951,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L3915-L3951","documentation":"Database.getFirstLogDate() executes a query for the maximum log_date of a logging table and wraps any SQLException in a KettleDatabaseException naming the log table. It means the log-date lookup query could not be executed against the given table.","triggerScenarios":"Calling getFirstLogDate(schemaTable, ...) / getLastLogDate where the log table name is wrong, the table has no log_date column, or the connection fails during pstmt.executeQuery().","commonSituations":"Misconfigured logging table names in transformation/job settings, renamed or dropped logging tables, schema prefix mismatch, or connecting to a fresh database with no logging tables created yet.","solutions":["Verify the log table exists and has the expected log_date column in the connected schema","Check the logging configuration (table name + schema) in your transformation/job log settings","Run the SQL shown in your DB console to reproduce the driver error","If the table is intentionally empty/missing, create the logging tables (SQL button in the log table settings)"],"exampleFix":"// before\ndb.getLastLogDate(\"\"KETTLE\".\"TRANS_LOG\"\", \"transname\", \"t\", \"transformation\", null);\n// after\n// confirm table exists, or create it first via logging settings, then:\ndb.getLastLogDate(\"\"KETTLE\".\"TRANSMETALOG\"\", \"transname\", \"t\", \"transformation\", null);","handlingStrategy":"validation","validationCode":"if (!db.checkTableExistsUnquoted(null, logtable)) {\n  throw new IllegalStateException(\"Log table missing: \" + logtable + \" — create logging tables first\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  RowMetaAndData last = db.getLastLogDate(logtable, name, id, type, status);\n} catch (KettleDatabaseException e) {\n  log.warn(\"No last log date for \" + logtable + \": \" + e.getMessage());\n  // proceed with default (no previous run)\n}","preventionTips":["Configure logging table names via the Logging tab so names are consistent","Create logging tables with the built-in SQL generator before first run","Verify schema/catalog prefixes match the connected user's defaults","Check permissions to SELECT on logging tables"],"tags":["jdbc","logging-table","sql"],"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"}