SlideShare une entreprise Scribd logo
Enhancements in Oracle 23c: Introducing the New/Old
Returning Clause
Oracle 23c brings a host of new features aimed at simplifying application development. One
standout feature is the enhanced Returning Clause for Data Manipulation Language (DML)
operations, which now includes the ability to work with both NEW and OLD values. This addition
empowers developers to streamline their code, boost productivity, and enhance performance.
Understanding the Returning Clause:
The RETURNING INTO clause for INSERT, UPDATE, and DELETE statements has undergone
signi
fi
cant improvements. It now provides a comprehensive report on the OLD and NEW values
a
ff
ected by the respective statement.
This means that developers can employ the same logic for all DML types to retrieve values before
and after the execution of a statement.
It’s important to note that old and new values are only applicable to UPDATE statements.
INSERT statements exclusively return new values, while DELETE statements only report old
values.
The Evolution from the Previous Norm:
Previously, Oracle’s returning clause primarily focused on providing new values. For example, in
cases where an application inserted data into a table, it would return an auto-generated ID for the
row. In the context of updates, developers could return the ID along with the updated row and
other relevant columns. While it was possible to retrieve old column values for updates through
some workarounds, it was by no means straightforward. Oracle’s commitment to simplifying the
process for application developers led to the introduction of this feature as a SQL clause.
Utilizing the New Returning Clause:
This newly enhanced feature allows developers to retrieve either a single row/value or multiple
rows/values, o
ff
ering a
fl
exible and dynamic approach to data manipulation. Let’s delve into a
example:
set serveroutput on
DROP table if exists TEST_TAB purge;
CREATE TABLE TEST_TAB (columnA VARCHAR2(10), columnB number);
INSERT INTO TEST_TAB(columnA, columnB) VALUES ('Test', 10);
INSERT INTO TEST_TAB(columnA, columnB) VALUES ('Row 2', 20);
CREATE TABLE IF not exists audit_table1(col_new VARCHAR2(10),col_old VARCHAR2(10),
columnB number);
DECLARE
TYPE columnA_TYPE IS TABLE OF TEST_TAB.columnA%TYPE;
OLD_columnA columnA_TYPE;
NEW_columnA columnA_TYPE;
BEGIN
UPDATE TEST_TAB AA
SET AA.columnA = 'NEW_VALUE'
WHERE AA.columnB < 30
RETURNING OLD columnA, NEW columnA
BULK COLLECT INTO OLD_columnA, NEW_columnA;
FOR I IN 1 .. OLD_columnA.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Old.columnA = ' || OLD_columnA(I));
DBMS_OUTPUT.PUT_LINE('New.columnA = ' || NEW_columnA(I));
--insert into audit_table1 values ( NEW_columnA, OLD_columnA);
END LOOP;
END;
Output
-------------------
Old.columnA = Test
New.columnA = NEW_VALUE
Old.columnA = Row 2
New.columnA = NEW_VALUE
Oracle 23c’s enhanced RETURNING clause can come in handy in application auditing,
Application level Change Data Capture, and many application-driven logic.
This powerful feature promises to be a game-changer for developers seeking code e
ffi
ciency,
precision, and performance in their applications.
Insert and Delete
The NEW and OLD keywords can be used on INSERT and DELETE also, but they don't bring
anything new to the table. For inserts we have no old values, and for deletes we have no new
values.
set serveroutput on
declare
l_old_code t1.code%type;
l_old_description t1.description%type;
l_new_code t1.code%type;
l_new_description t1.description%type;
begin
insert into t1 (id, code, description)
values (5, 'FIVE', 'Description for FIVE')
returning old code , old description, new code, new description
into l_old_code, l_old_description, l_new_code, l_new_description;
dbms_output.put_line('l_old_code = ' || l_old_code);
dbms_output.put_line('l_old_description = ' || l_old_description);
dbms_output.put_line('l_new_code = ' || l_new_code);
dbms_output.put_line('l_new_description = ' || l_new_description);
rollback;
END;
/
------------------
l_old_code =
l_old_description =
l_new_code = FIVE
l_new_description = Description for FIVE
PL/SQL procedure successfully completed.
SQL>
--------------------------
set serveroutput on
declare
l_old_code t1.code%type;
l_old_description t1.description%type;
l_new_code t1.code%type;
l_new_description t1.description%type;
begin
delete from t1
where id = 2
returning old code , old description, new code, new description
into l_old_code, l_old_description, l_new_code, l_new_description;
dbms_output.put_line('l_old_code = ' || l_old_code);
dbms_output.put_line('l_old_description = ' || l_old_description);
dbms_output.put_line('l_new_code = ' || l_new_code);
dbms_output.put_line('l_new_description = ' || l_new_description);
rollback;
END;
/
l_old_code = TWO
l_old_description = Description for TWO
l_new_code =
l_new_description =
PL/SQL procedure successfully completed.
SQL>
Also you can use this feature instead of Golden gate to achieve xhange data capture (CDC) using
some manually scripts.
Alireza Kamrani.

Contenu connexe

Similaire à Enhancements in Oracle 23c Introducing the NewOld Returning Clause

Oracle_Analytical_function.pdf
Oracle_Analytical_function.pdfOracle_Analytical_function.pdf
Oracle_Analytical_function.pdf
KalyankumarVenkat1
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
Achmad Solichin
 
Les08
Les08Les08
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
Rushdi Shams
 
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
The Ultimate Guide to Oracle solaris 11 advanced system administration  1 z0 822The Ultimate Guide to Oracle solaris 11 advanced system administration  1 z0 822
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
SoniaSrivastva
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
Rodrigo Bastos
 
PL/SQL 3 DML
PL/SQL 3 DMLPL/SQL 3 DML
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
FilestreamFilestream
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
Edgar Alejandro Villegas
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
Vaibhav Kathuria
 
plsql Les08
plsql Les08 plsql Les08
plsql Les08
sasa_eldoby
 
Chapter09
Chapter09Chapter09
Chapter09
sasa_eldoby
 
Scalar user defined function in sap hana
Scalar user defined function in sap hanaScalar user defined function in sap hana
Scalar user defined function in sap hana
kabilarasan R
 
SQL Procedures & Functions
SQL Procedures & FunctionsSQL Procedures & Functions
SQL Procedures & Functions
JeevananthamArumugam
 
New features of SQL 2012
New features of SQL 2012New features of SQL 2012
New features of SQL 2012
Mindfire Solutions
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
Alan737817
 
Les08
Les08Les08
Les18[1]Interacting with the Oracle Server
Les18[1]Interacting with  the Oracle ServerLes18[1]Interacting with  the Oracle Server
Les18[1]Interacting with the Oracle Server
siavosh kaviani
 

Similaire à Enhancements in Oracle 23c Introducing the NewOld Returning Clause (20)

Oracle_Analytical_function.pdf
Oracle_Analytical_function.pdfOracle_Analytical_function.pdf
Oracle_Analytical_function.pdf
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
 
Les08
Les08Les08
Les08
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
The Ultimate Guide to Oracle solaris 11 advanced system administration  1 z0 822The Ultimate Guide to Oracle solaris 11 advanced system administration  1 z0 822
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
 
PL/SQL 3 DML
PL/SQL 3 DMLPL/SQL 3 DML
PL/SQL 3 DML
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
Sql DML
Sql DMLSql DML
Sql DML
 
Sql DML
Sql DMLSql DML
Sql DML
 
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
plsql Les08
plsql Les08 plsql Les08
plsql Les08
 
Chapter09
Chapter09Chapter09
Chapter09
 
Scalar user defined function in sap hana
Scalar user defined function in sap hanaScalar user defined function in sap hana
Scalar user defined function in sap hana
 
SQL Procedures & Functions
SQL Procedures & FunctionsSQL Procedures & Functions
SQL Procedures & Functions
 
New features of SQL 2012
New features of SQL 2012New features of SQL 2012
New features of SQL 2012
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
 
Les08
Les08Les08
Les08
 
Les18[1]Interacting with the Oracle Server
Les18[1]Interacting with  the Oracle ServerLes18[1]Interacting with  the Oracle Server
Les18[1]Interacting with the Oracle Server
 

Plus de Alireza Kamrani

How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Oracle PDB Failover in a Data Guard environment
Oracle PDB Failover in a Data Guard environmentOracle PDB Failover in a Data Guard environment
Oracle PDB Failover in a Data Guard environment
Alireza Kamrani
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Alireza Kamrani
 
Recovering a oracle datafile without backup
Recovering a oracle datafile without backupRecovering a oracle datafile without backup
Recovering a oracle datafile without backup
Alireza Kamrani
 
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in OracleEDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
Alireza Kamrani
 
Oracle Application Continuity with Oracle RAC for java
Oracle Application Continuity with Oracle RAC for javaOracle Application Continuity with Oracle RAC for java
Oracle Application Continuity with Oracle RAC for java
Alireza Kamrani
 
Oracle database maximum performance on Exadata
Oracle database maximum performance on ExadataOracle database maximum performance on Exadata
Oracle database maximum performance on Exadata
Alireza Kamrani
 
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdfClone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
Alireza Kamrani
 
Flashback time travel vs Flash back Data Archive.pdf
Flashback time travel  vs Flash back Data Archive.pdfFlashback time travel  vs Flash back Data Archive.pdf
Flashback time travel vs Flash back Data Archive.pdf
Alireza Kamrani
 
Import option in Oracle Database : tip & trick🧶.pdf
Import option in Oracle Database : tip & trick🧶.pdfImport option in Oracle Database : tip & trick🧶.pdf
Import option in Oracle Database : tip & trick🧶.pdf
Alireza Kamrani
 
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
Alireza Kamrani
 
Recovering a Oracle datafile without backup.pdf
Recovering a Oracle datafile without backup.pdfRecovering a Oracle datafile without backup.pdf
Recovering a Oracle datafile without backup.pdf
Alireza Kamrani
 
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
Alireza Kamrani
 
♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instance♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instance
Alireza Kamrani
 
Out-of-Place Oracle Database Patching and Provisioning Golden Images
Out-of-Place Oracle Database Patching and Provisioning Golden ImagesOut-of-Place Oracle Database Patching and Provisioning Golden Images
Out-of-Place Oracle Database Patching and Provisioning Golden Images
Alireza Kamrani
 
IO Schedulers (Elevater) concept and its affection on database performance
IO Schedulers (Elevater) concept and its affection on database performanceIO Schedulers (Elevater) concept and its affection on database performance
IO Schedulers (Elevater) concept and its affection on database performance
Alireza Kamrani
 
The Fundamental Characteristics of Storage concepts for DBAs
The Fundamental Characteristics of Storage concepts for DBAsThe Fundamental Characteristics of Storage concepts for DBAs
The Fundamental Characteristics of Storage concepts for DBAs
Alireza Kamrani
 
What is Scalability and How can affect on overall system performance of database
What is Scalability and How can affect on overall system performance of databaseWhat is Scalability and How can affect on overall system performance of database
What is Scalability and How can affect on overall system performance of database
Alireza Kamrani
 
🏗️Improve database performance with connection pooling and load balancing tec...
🏗️Improve database performance with connection pooling and load balancing tec...🏗️Improve database performance with connection pooling and load balancing tec...
🏗️Improve database performance with connection pooling and load balancing tec...
Alireza Kamrani
 
Oracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking featuresOracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking features
Alireza Kamrani
 

Plus de Alireza Kamrani (20)

How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
Oracle PDB Failover in a Data Guard environment
Oracle PDB Failover in a Data Guard environmentOracle PDB Failover in a Data Guard environment
Oracle PDB Failover in a Data Guard environment
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
 
Recovering a oracle datafile without backup
Recovering a oracle datafile without backupRecovering a oracle datafile without backup
Recovering a oracle datafile without backup
 
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in OracleEDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
 
Oracle Application Continuity with Oracle RAC for java
Oracle Application Continuity with Oracle RAC for javaOracle Application Continuity with Oracle RAC for java
Oracle Application Continuity with Oracle RAC for java
 
Oracle database maximum performance on Exadata
Oracle database maximum performance on ExadataOracle database maximum performance on Exadata
Oracle database maximum performance on Exadata
 
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdfClone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
Clone_a_remote_PDB_in_Data_Guard_Environments_19c_1698741799.pdf
 
Flashback time travel vs Flash back Data Archive.pdf
Flashback time travel  vs Flash back Data Archive.pdfFlashback time travel  vs Flash back Data Archive.pdf
Flashback time travel vs Flash back Data Archive.pdf
 
Import option in Oracle Database : tip & trick🧶.pdf
Import option in Oracle Database : tip & trick🧶.pdfImport option in Oracle Database : tip & trick🧶.pdf
Import option in Oracle Database : tip & trick🧶.pdf
 
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
🔴Oracle ASM Filter Driver & ASMLIB & UDEV🔴.pdf
 
Recovering a Oracle datafile without backup.pdf
Recovering a Oracle datafile without backup.pdfRecovering a Oracle datafile without backup.pdf
Recovering a Oracle datafile without backup.pdf
 
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
♨️How To Use DataPump (EXPDP) To Export From Physical Standby….pdf
 
♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instance♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instance
 
Out-of-Place Oracle Database Patching and Provisioning Golden Images
Out-of-Place Oracle Database Patching and Provisioning Golden ImagesOut-of-Place Oracle Database Patching and Provisioning Golden Images
Out-of-Place Oracle Database Patching and Provisioning Golden Images
 
IO Schedulers (Elevater) concept and its affection on database performance
IO Schedulers (Elevater) concept and its affection on database performanceIO Schedulers (Elevater) concept and its affection on database performance
IO Schedulers (Elevater) concept and its affection on database performance
 
The Fundamental Characteristics of Storage concepts for DBAs
The Fundamental Characteristics of Storage concepts for DBAsThe Fundamental Characteristics of Storage concepts for DBAs
The Fundamental Characteristics of Storage concepts for DBAs
 
What is Scalability and How can affect on overall system performance of database
What is Scalability and How can affect on overall system performance of databaseWhat is Scalability and How can affect on overall system performance of database
What is Scalability and How can affect on overall system performance of database
 
🏗️Improve database performance with connection pooling and load balancing tec...
🏗️Improve database performance with connection pooling and load balancing tec...🏗️Improve database performance with connection pooling and load balancing tec...
🏗️Improve database performance with connection pooling and load balancing tec...
 
Oracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking featuresOracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking features
 

Dernier

writing report business partner b1+ .pdf
writing report business partner b1+ .pdfwriting report business partner b1+ .pdf
writing report business partner b1+ .pdf
VyNguyen709676
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
y3i0qsdzb
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
taqyea
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
Márton Kodok
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
Social Samosa
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
xclpvhuk
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
Walaa Eldin Moustafa
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 

Dernier (20)

writing report business partner b1+ .pdf
writing report business partner b1+ .pdfwriting report business partner b1+ .pdf
writing report business partner b1+ .pdf
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
一比一原版巴斯大学毕业证(Bath毕业证书)学历如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 

Enhancements in Oracle 23c Introducing the NewOld Returning Clause

  • 1. Enhancements in Oracle 23c: Introducing the New/Old Returning Clause Oracle 23c brings a host of new features aimed at simplifying application development. One standout feature is the enhanced Returning Clause for Data Manipulation Language (DML) operations, which now includes the ability to work with both NEW and OLD values. This addition empowers developers to streamline their code, boost productivity, and enhance performance. Understanding the Returning Clause: The RETURNING INTO clause for INSERT, UPDATE, and DELETE statements has undergone signi fi cant improvements. It now provides a comprehensive report on the OLD and NEW values a ff ected by the respective statement. This means that developers can employ the same logic for all DML types to retrieve values before and after the execution of a statement. It’s important to note that old and new values are only applicable to UPDATE statements. INSERT statements exclusively return new values, while DELETE statements only report old values. The Evolution from the Previous Norm: Previously, Oracle’s returning clause primarily focused on providing new values. For example, in cases where an application inserted data into a table, it would return an auto-generated ID for the row. In the context of updates, developers could return the ID along with the updated row and other relevant columns. While it was possible to retrieve old column values for updates through some workarounds, it was by no means straightforward. Oracle’s commitment to simplifying the process for application developers led to the introduction of this feature as a SQL clause. Utilizing the New Returning Clause: This newly enhanced feature allows developers to retrieve either a single row/value or multiple rows/values, o ff ering a fl exible and dynamic approach to data manipulation. Let’s delve into a example: set serveroutput on DROP table if exists TEST_TAB purge; CREATE TABLE TEST_TAB (columnA VARCHAR2(10), columnB number); INSERT INTO TEST_TAB(columnA, columnB) VALUES ('Test', 10); INSERT INTO TEST_TAB(columnA, columnB) VALUES ('Row 2', 20); CREATE TABLE IF not exists audit_table1(col_new VARCHAR2(10),col_old VARCHAR2(10), columnB number); DECLARE TYPE columnA_TYPE IS TABLE OF TEST_TAB.columnA%TYPE; OLD_columnA columnA_TYPE; NEW_columnA columnA_TYPE; BEGIN UPDATE TEST_TAB AA SET AA.columnA = 'NEW_VALUE' WHERE AA.columnB < 30
  • 2. RETURNING OLD columnA, NEW columnA BULK COLLECT INTO OLD_columnA, NEW_columnA; FOR I IN 1 .. OLD_columnA.COUNT LOOP DBMS_OUTPUT.PUT_LINE('Old.columnA = ' || OLD_columnA(I)); DBMS_OUTPUT.PUT_LINE('New.columnA = ' || NEW_columnA(I)); --insert into audit_table1 values ( NEW_columnA, OLD_columnA); END LOOP; END; Output ------------------- Old.columnA = Test New.columnA = NEW_VALUE Old.columnA = Row 2 New.columnA = NEW_VALUE Oracle 23c’s enhanced RETURNING clause can come in handy in application auditing, Application level Change Data Capture, and many application-driven logic. This powerful feature promises to be a game-changer for developers seeking code e ffi ciency, precision, and performance in their applications. Insert and Delete The NEW and OLD keywords can be used on INSERT and DELETE also, but they don't bring anything new to the table. For inserts we have no old values, and for deletes we have no new values. set serveroutput on declare l_old_code t1.code%type; l_old_description t1.description%type; l_new_code t1.code%type; l_new_description t1.description%type; begin insert into t1 (id, code, description) values (5, 'FIVE', 'Description for FIVE') returning old code , old description, new code, new description into l_old_code, l_old_description, l_new_code, l_new_description; dbms_output.put_line('l_old_code = ' || l_old_code); dbms_output.put_line('l_old_description = ' || l_old_description); dbms_output.put_line('l_new_code = ' || l_new_code); dbms_output.put_line('l_new_description = ' || l_new_description); rollback; END; / ------------------ l_old_code = l_old_description = l_new_code = FIVE l_new_description = Description for FIVE PL/SQL procedure successfully completed.
  • 3. SQL> -------------------------- set serveroutput on declare l_old_code t1.code%type; l_old_description t1.description%type; l_new_code t1.code%type; l_new_description t1.description%type; begin delete from t1 where id = 2 returning old code , old description, new code, new description into l_old_code, l_old_description, l_new_code, l_new_description; dbms_output.put_line('l_old_code = ' || l_old_code); dbms_output.put_line('l_old_description = ' || l_old_description); dbms_output.put_line('l_new_code = ' || l_new_code); dbms_output.put_line('l_new_description = ' || l_new_description); rollback; END; / l_old_code = TWO l_old_description = Description for TWO l_new_code = l_new_description = PL/SQL procedure successfully completed. SQL> Also you can use this feature instead of Golden gate to achieve xhange data capture (CDC) using some manually scripts. Alireza Kamrani.