{"record":{"id":"421427d586e59e24","repo":"pentaho/pentaho-kettle","slug":"unable-to-determine-if-indexes-exists-on-table-tablename-421427","errorCode":null,"errorMessage":"Unable to determine if indexes exists on table [\" + tablename + \"]","messagePattern":"Unable to determine if indexes exists on table \\[\" \\+ tablename \\+ \"\\]","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/OracleDatabaseMeta.java","lineNumber":540,"sourceCode":"          return false;\n        }\n      } finally {\n        if ( res != null ) {\n          database.closeQuery( res );\n        }\n      }\n\n      // See if all the fields are indexed...\n      boolean all = true;\n      for ( int i = 0; i < exists.length && all; i++ ) {\n        if ( !exists[i] ) {\n          all = false;\n        }\n      }\n\n      return all;\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Unable to determine if indexes exists on table [\" + tablename + \"]\", e );\n    }\n  }\n\n  @Override\n  public boolean requiresCreateTablePrimaryKeyAppend() {\n    return true;\n  }\n\n  /**\n   * @return The maximum number of columns in a database, <=0 means: no known limit\n   */\n  @Override\n  public int getMaxColumnsInIndex() {\n    return 32;\n  }\n\n  /**\n   * @return The SQL on this database to get a list of sequences.","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/OracleDatabaseMeta.java#L522-L558","documentation":"OracleDatabaseMeta.checkIndexExists wraps any Exception encountered while checking whether indexes exist on a table, rethrowing as a KettleDatabaseException naming the table. The underlying check inspects index metadata; any driver/SQL error surfaces under this message.","triggerScenarios":"Calling checkIndexExists(db, tablename, schemas) and the underlying index-lookup (JDBC metadata query or SQL against all_indexes-style catalogs) throws — bad table name, missing permissions on catalog views, or connection failure.","commonSituations":"Index existence checks before CREATE INDEX during table optimization; table name with wrong case/quoting; user lacking privileges to view Oracle metadata dictionary views.","solutions":["Verify the table name (case, schema qualification) exists on the Oracle instance","Grant the connecting user privileges to the relevant metadata dictionary views (e.g. USER_INDEXES/ALL_INDEXES)","Inspect the chained cause for the root driver error and fix connectivity/schema accordingly"],"exampleFix":"// before\nboolean exists = oracleMeta.checkIndexExists(db, \"MyTable\", new String[]{null});\n// after\nboolean exists = oracleMeta.checkIndexExists(db, \"MYTABLE\", new String[]{\"MYSCHEMA\"}); // correct case + schema\n","handlingStrategy":"try-catch","validationCode":"if (tablename == null || tablename.trim().isEmpty()) throw new IllegalArgumentException(\"Table name required for index check\");\n// optionally verify table exists first: db.getTableFields(tablename)","typeGuard":"function canCheckIndexes(String tablename) { return tablename != null && !tablename.trim().isEmpty(); }","tryCatchPattern":"try {\n  boolean ok = oracleMeta.checkIndexExists(db, tablename, schemas);\n} catch (KettleDatabaseException e) {\n  Throwable cause = e.getCause(); // driver/SQL error: table name, privileges, connectivity\n  log.error(\"Index existence check failed on table \" + tablename + \": \" + (cause != null ? cause.getMessage() : e.getMessage()), e);\n}","preventionTips":["Use the exact (correctly cased/quoted) Oracle table name and qualify with schema","Ensure the connecting user can read the Oracle metadata dictionary views","Verify connectivity before running catalog/metadata checks"],"tags":["oracle","jdbc","metadata","index"],"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"}