At a customer site, I recently refactored a "slow-by-slow" PL/SQL loop and turned that into an efficient set based UPDATE statement saving many lines of code and running much faster. In this blog post, I will show how that can be done. The blog post will focus on Oracle and UPDATE, but rest assured, this … Continue reading How to Use SQL UPDATE .. RETURNING to Run DML More Efficiently
Tag: INSERT RETURNING
How to Run a Bulk INSERT .. RETURNING Statement With Oracle and JDBC
When inserting records into SQL databases, we often want to fetch back generated IDs and possibly other trigger, sequence, or default generated values. Let's assume we have the following table: -- DB2 CREATE TABLE x ( i INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, j VARCHAR(50), k DATE DEFAULT CURRENT_DATE ); -- PostgreSQL CREATE TABLE … Continue reading How to Run a Bulk INSERT .. RETURNING Statement With Oracle and JDBC
Postgres INSERT .. RETURNING clause and how this can be simulated in other RDBMS
One of jOOQ's major features is to take the most useful SQL constructs and clauses from any RDBMS and make them available to other SQL dialects, as well. This had been done previously with MySQL's INSERT .. ON DUPLICATE KEY UPDATE construct, which can be easily simulated with the more powerful SQL standard MERGE statement, … Continue reading Postgres INSERT .. RETURNING clause and how this can be simulated in other RDBMS