SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
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.

Más contenido relacionado

Similar a Enhancements in Oracle 23c Introducing the NewOld Returning Clause

Oracle_Analytical_function.pdf
Oracle_Analytical_function.pdfOracle_Analytical_function.pdf
Oracle_Analytical_function.pdfKalyankumarVenkat1
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)Achmad Solichin
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programmingRushdi 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 822SoniaSrivastva
 
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 - 2431343Edgar Alejandro Villegas
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, proceduresVaibhav Kathuria
 
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 hanakabilarasan R
 
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 Serversiavosh kaviani
 

Similar a 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
 

Más de Alireza Kamrani

Recovering a oracle datafile without backup
Recovering a oracle datafile without backupRecovering a oracle datafile without backup
Recovering a oracle datafile without backupAlireza 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 OracleAlireza 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 javaAlireza Kamrani
 
Oracle database maximum performance on Exadata
Oracle database maximum performance on ExadataOracle database maximum performance on Exadata
Oracle database maximum performance on ExadataAlireza 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.pdfAlireza 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.pdfAlireza 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🧶.pdfAlireza 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🔴.pdfAlireza 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.pdfAlireza 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….pdfAlireza Kamrani
 
♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instance♨️CPU limitation per Oracle database instance
♨️CPU limitation per Oracle database instanceAlireza 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 ImagesAlireza 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 performanceAlireza 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 DBAsAlireza 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 databaseAlireza 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 featuresAlireza Kamrani
 
Store non-structured data in JSON column types and enhancements of JSON
Store non-structured data in JSON column types and enhancements of JSONStore non-structured data in JSON column types and enhancements of JSON
Store non-structured data in JSON column types and enhancements of JSONAlireza Kamrani
 
PostgreSQL vs Oracle a brief comparison
PostgreSQL vs Oracle a brief  comparisonPostgreSQL vs Oracle a brief  comparison
PostgreSQL vs Oracle a brief comparisonAlireza Kamrani
 
How to take a dump from a Wal file PostgreSQL
How to take a dump from a Wal file PostgreSQLHow to take a dump from a Wal file PostgreSQL
How to take a dump from a Wal file PostgreSQLAlireza Kamrani
 

Más de Alireza Kamrani (20)

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
 
Store non-structured data in JSON column types and enhancements of JSON
Store non-structured data in JSON column types and enhancements of JSONStore non-structured data in JSON column types and enhancements of JSON
Store non-structured data in JSON column types and enhancements of JSON
 
PostgreSQL vs Oracle a brief comparison
PostgreSQL vs Oracle a brief  comparisonPostgreSQL vs Oracle a brief  comparison
PostgreSQL vs Oracle a brief comparison
 
How to take a dump from a Wal file PostgreSQL
How to take a dump from a Wal file PostgreSQLHow to take a dump from a Wal file PostgreSQL
How to take a dump from a Wal file PostgreSQL
 

Último

Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Valters Lauzums
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证ppy8zfkfm
 
一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理cyebo
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证zifhagzkk
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证pwgnohujw
 
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...ssuserf63bd7
 
2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group MeetingAlison Pitt
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理pyhepag
 
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...BabaJohn3
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理pyhepag
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证dq9vz1isj
 
Aggregations - The Elasticsearch "GROUP BY"
Aggregations - The Elasticsearch "GROUP BY"Aggregations - The Elasticsearch "GROUP BY"
Aggregations - The Elasticsearch "GROUP BY"John Sobanski
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunksgmuir1066
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Jon Hansen
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancingmohamed Elzalabany
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024patrickdtherriault
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Klinik Aborsi
 

Último (20)

Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
 
一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理
 
123.docx. .
123.docx.                                 .123.docx.                                 .
123.docx. .
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
 
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
 
2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
 
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
 
Aggregations - The Elasticsearch "GROUP BY"
Aggregations - The Elasticsearch "GROUP BY"Aggregations - The Elasticsearch "GROUP BY"
Aggregations - The Elasticsearch "GROUP BY"
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancing
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
 

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.