{"record":{"id":"e288b93feed0073a","repo":"prestodb/presto","slug":"sql-is-not-an-update-statement","errorCode":null,"errorMessage":"SQL is not an update statement: ","messagePattern":"SQL is not an update statement: ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java","lineNumber":511,"sourceCode":"    public int executeUpdate(String sql, int[] columnIndexes)\n            throws SQLException\n    {\n        return executeUpdate(sql);\n    }\n\n    @Override\n    public int executeUpdate(String sql, String[] columnNames)\n            throws SQLException\n    {\n        return executeUpdate(sql);\n    }\n\n    @Override\n    public long executeLargeUpdate(String sql)\n            throws SQLException\n    {\n        if (execute(sql)) {\n            throw new SQLException(\"SQL is not an update statement: \" + sql);\n        }\n        return currentUpdateCount.get();\n    }\n\n    @Override\n    public long executeLargeUpdate(String sql, int autoGeneratedKeys)\n            throws SQLException\n    {\n        return executeLargeUpdate(sql);\n    }\n\n    @Override\n    public long executeLargeUpdate(String sql, int[] columnIndexes)\n            throws SQLException\n    {\n        return executeLargeUpdate(sql);\n    }\n","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java#L493-L529","documentation":"executeLargeUpdate(String) runs execute(sql); if it returns true the statement produced a result set, meaning the SQL was a query rather than an update, so this SQLException is thrown with the offending SQL appended. It fires when DML/DDL-style APIs are pointed at SELECT statements.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:511 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use executeQuery() for SELECT statements and executeUpdate() only for DML/DDL","Branch on the boolean returned by execute() when the statement type is dynamic","Wrap calls in try-catch when routing user-supplied SQL"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}