[#5190] Support UPDATE and DELETE RETURNING for Oracle using PL/SQL RETURNING .. INTO
This commit is contained in:
parent
6d144fddbf
commit
a2e6285060
@ -43,6 +43,7 @@ package org.jooq;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -45,6 +45,7 @@ import static java.util.Arrays.asList;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.RenderNameStyle.LOWER;
|
||||
import static org.jooq.conf.RenderNameStyle.UPPER;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
@ -52,6 +53,7 @@ import static org.jooq.impl.Tools.fieldArray;
|
||||
import static org.jooq.impl.Tools.unqualify;
|
||||
import static org.jooq.util.sqlite.SQLiteDSL.rowid;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -64,6 +66,7 @@ import java.util.List;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.DeleteQuery;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Field;
|
||||
@ -72,6 +75,7 @@ import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UpdateQuery;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.impl.Tools.DataKey;
|
||||
import org.jooq.tools.jdbc.JDBCUtils;
|
||||
@ -155,11 +159,39 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
accept0(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
abstract void accept0(Context<?> ctx);
|
||||
|
||||
final void toSQLReturning(Context<?> ctx) {
|
||||
@ -251,6 +283,15 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case HSQLDB:
|
||||
default: {
|
||||
List<String> names = new ArrayList<String>();
|
||||
@ -278,6 +319,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
protected final int execute(ExecuteContext ctx, ExecuteListener listener) throws SQLException {
|
||||
if (returning.isEmpty()) {
|
||||
@ -357,11 +399,9 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
|
||||
// Some JDBC drivers seem to illegally return null
|
||||
// from getGeneratedKeys() sometimes
|
||||
if (rs != null) {
|
||||
while (rs.next()) {
|
||||
if (rs != null)
|
||||
while (rs.next())
|
||||
list.add(rs.getObject(1));
|
||||
}
|
||||
}
|
||||
|
||||
selectReturning(ctx.configuration(), list.toArray());
|
||||
return result;
|
||||
@ -391,6 +431,35 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case HSQLDB:
|
||||
default: {
|
||||
listener.executeStart(ctx);
|
||||
|
||||
@ -71,7 +71,6 @@ import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.conf.ParamType;
|
||||
@ -86,14 +85,14 @@ import org.jooq.tools.JooqLogger;
|
||||
*/
|
||||
abstract class AbstractQuery extends AbstractQueryPart implements Query, AttachableInternal {
|
||||
|
||||
private static final long serialVersionUID = -8046199737354507547L;
|
||||
private static final JooqLogger log = JooqLogger.getLogger(AbstractQuery.class);
|
||||
private static final long serialVersionUID = -8046199737354507547L;
|
||||
private static final JooqLogger log = JooqLogger.getLogger(AbstractQuery.class);
|
||||
|
||||
private Configuration configuration;
|
||||
private int timeout;
|
||||
private boolean keepStatement;
|
||||
private transient PreparedStatement statement;
|
||||
private transient Rendered rendered;
|
||||
private Configuration configuration;
|
||||
private int timeout;
|
||||
private boolean keepStatement;
|
||||
transient PreparedStatement statement;
|
||||
transient Rendered rendered;
|
||||
|
||||
AbstractQuery(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
@ -453,15 +452,15 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class Rendered {
|
||||
String sql;
|
||||
QueryPart bindValues;
|
||||
static class Rendered {
|
||||
String sql;
|
||||
QueryPartList<Param<?>> bindValues;
|
||||
|
||||
Rendered(String sql) {
|
||||
this(sql, null);
|
||||
}
|
||||
|
||||
Rendered(String sql, QueryPart bindValues) {
|
||||
Rendered(String sql, QueryPartList<Param<?>> bindValues) {
|
||||
this.sql = sql;
|
||||
this.bindValues = bindValues;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
final QueryPart bindValues() {
|
||||
final QueryPartList<Param<?>> bindValues() {
|
||||
return bindValues;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user