{"record":{"id":"fcff579c4a7baa9f","repo":"pentaho/pentaho-kettle","slug":"unexpected-error-checking-whether-or-not-sequence","errorCode":null,"errorMessage":"Unexpected error checking whether or not sequence [\" + schemaSequence + \"] exists","messagePattern":"Unexpected error checking whether or not sequence \\[\" \\+ schemaSequence \\+ \"\\] exists","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":2405,"sourceCode":"      return retval;\n    }\n\n    String schemaSequence = databaseMeta.getQuotedSchemaTableCombination( schemaName, sequenceName );\n    try {\n      //\n      // Get the info from the data dictionary...\n      //\n      String sql = databaseMeta.getSQLSequenceExists( schemaSequence );\n      ResultSet res = openQuery( sql );\n      if ( res != null ) {\n        Object[] row = getRow( res );\n        if ( row != null ) {\n          retval = true;\n        }\n        closeQuery( res );\n      }\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Unexpected error checking whether or not sequence [\"\n        + schemaSequence + \"] exists\", e );\n    }\n\n    return retval;\n  }\n\n  /**\n   * Check if an index on certain fields in a table exists.\n   *\n   * @param tableName The table on which the index is checked\n   * @param idxFields The fields on which the index is checked\n   * @return True if the index exists\n   */\n  public boolean checkIndexExists( String tableName, String[] idxFields ) throws KettleDatabaseException {\n    return checkIndexExists( null, tableName, idxFields );\n  }\n\n  /**","sourceCodeStart":2387,"sourceCodeEnd":2423,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L2387-L2423","documentation":"Raised by getCheckSumSequence-style sequence existence checks (Oracle) when any unexpected Exception occurs while probing the sequence. It wraps the cause and names the schema-qualified sequence that was being checked.","triggerScenarios":"Exception during the sequence-existence SELECT (e.g. FROM user_sequences/all_sequences query) inside the try block, such as connection failure or driver error.","commonSituations":"Checking sequences on non-Oracle databases via the Oracle-only path, missing SELECT privileges on data dictionary views, or dead connections.","solutions":["Confirm you are connected to Oracle; sequence checks are Oracle-specific","Ensure the user can read USER_SEQUENCES/ALL_SEQUENCES dictionary views","Reconnect if the session died, then retry the check","Verify the schema and sequence name spelling/casing"],"exampleFix":"// before\nboolean s = db.checkSequenceExists(\"MYSCHEMA\", \"MYSEQ\"); // on PostgreSQL\n// after\nif (meta.getDatabaseInterface() instanceof OracleDatabaseMeta) {\n  boolean s = db.checkSequenceExists(\"MYSCHEMA\", \"MYSEQ\");\n}","handlingStrategy":"validation","validationCode":"// Oracle-only check\nif (!(dbMeta.getDatabaseInterface() instanceof OracleDatabaseMeta)) {\n  throw new UnsupportedOperationException(\"sequence checks are Oracle-only\");\n}","typeGuard":"boolean isOracle(DatabaseMeta meta) {\n  return \"Oracle\".equals(meta.getPluginId());\n}","tryCatchPattern":"try {\n  boolean exists = db.checkSequenceExists(schema, seq);\n} catch (KettleDatabaseException e) {\n  log.error(\"sequence probe failed: \" + e.getCause(), e);\n}","preventionTips":["Only call sequence checks against Oracle","Verify SELECT privileges on dictionary views","Check sequence name spelling and casing"],"tags":["oracle","sequence","jdbc"],"backgroundTag":"database-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"}