{"record":{"id":"c46afef3953a645f","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-rowcount-c46afe","errorCode":null,"errorMessage":"No result returned after running query [${rowCountQuery}]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java","lineNumber":271,"sourceCode":"            String rowCountQuery =\n                    String.format(\n                            \"select NUM_ROWS from all_tables where OWNER = '%s' AND TABLE_NAME = '%s' \",\n                            tablePath.getSchemaName(), tablePath.getTableName());\n            try (Statement stmt = connection.createStatement()) {\n                String analyzeTable =\n                        String.format(\n                                \"analyze table %s compute statistics for table\",\n                                tableIdentifier(tablePath));\n                if (!table.getSkipAnalyze()) {\n                    log.info(\"Split Chunk, approximateRowCntStatement: {}\", analyzeTable);\n                    stmt.execute(analyzeTable);\n                } else {\n                    log.warn(\"Skip analyze, approximateRowCntStatement: {}\", analyzeTable);\n                }\n                log.info(\"Split Chunk, approximateRowCntStatement: {}\", rowCountQuery);\n                try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {\n                    if (!rs.next()) {\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\",\n                                        rowCountQuery));\n                    }\n                    return rs.getLong(1);\n                }\n            }\n        }\n        return SQLUtils.countForSubquery(connection, query);\n    }\n\n    @Override\n    public Object queryNextChunkMax(\n            Connection connection,\n            JdbcSourceTable table,\n            String columnName,\n            int chunkSize,\n            Object includedLowerBound)","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java#L253-L289","documentation":"OracleDialect.approximateRowCntStatement runs an analyze + row-count query and reads the count from column 1. If the ResultSet has no first row, it throws this SQLException, because the chunk splitter needs an approximate row count to size splits.","triggerScenarios":"The rowCountQuery executed against Oracle returns an empty ResultSet — e.g. the table does not exist/is not visible to the user, or the statement form is invalid on that Oracle version.","commonSituations":"Wrong schema/user (table lives in another schema without a synonym); missing SELECT privileges; Oracle version whose approximate-count statement form is unsupported; typo in table/database config.","solutions":["Run the logged rowCountQuery manually as the same Oracle user to see the actual result/error.","Grant SELECT on the table (and stats views) to the connection user, or qualify the table with its schema owner.","Verify the configured schema/table name and that the dialect's count statement matches your Oracle version.","Upgrade the connector if your Oracle version changed the statement output."],"exampleFix":"// before\nurl = \"jdbc:oracle:thin:@host:1521/ORCL\"  table = \"MYTABLE\"  (owned by APP schema)\n// after\ntable = \"APP.MYTABLE\"  (or GRANT SELECT ON APP.MYTABLE TO etl_user;)","handlingStrategy":"validation","validationCode":"// Verify the count query returns a row before running the job\ntry (ResultSet rs = stmt.executeQuery(rowCountQuery)) {\n    if (!rs.next()) throw new IllegalStateException(\"Oracle row-count query returned no rows for \" + tableName);\n}","typeGuard":null,"tryCatchPattern":"catch (SQLException e) { if (e.getMessage().contains(\"No result returned\")) { /* check table visibility/privileges, retry or fall back to COUNT(*) */ } }","preventionTips":["Grant SELECT on the target table and stats views to the connection user","Qualify tables with their schema owner in config","Run the logged rowCountQuery manually against Oracle before chunked reads"],"tags":["jdbc","oracle","sql","chunk-splitting"],"backgroundTag":"empty-result-set","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}