SlideShare uma empresa Scribd logo
1 de 10
Carlos Oliveira / July 23, 2014
Agenda
 Code Refactoring – From anonymous block to
procedure
 Introduction
 Quote
 Code Refactoring
 Benefits
 Next Steps
 Training & Reference
 Thank You
Introduction
I am a forward-looking Information Systems Architect with a
solid Oracle DBA background comprising the daily
infrastructure tasks of the DBA, several projects as a Data
Modeler, and performance management projects.
I Started on the mainframe business, and soon had a deep dive
in application development for Oracle databases. After
acquiring an Oracle certification, I worked on performance
enhancement for applications using Oracle databases, and later
worked several years as an infrastructure DBA, later I worked
on data modeling projects and more recently a performance
management project, on both application and database layers.
“The limits of my language
mean the limits of my world.”
Ludwig Wittgenstein
Code Refactoring
Script_text_file_01.sql – file contents below
DECLARE
/********************************************************
Description: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Changed: xx/xx/xxxx
Changed By: xxxxxxx
********************************************************/
v_msg_text VARCHAR2(4000);
v_msg_num NUMBER(10) := 0;
BEGIN
v_msg_text := 'Procedure executed';
v_msg_num := 1;
END;
/
quit
Code Refactoring
CREATE OR REPLACE PROCEDURE DB_USER.PROC_NAME IS
/********************************************************
Description: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Changed: xx/xx/xxxx
Changed By: xxxxxxx
********************************************************/
v_msg_text VARCHAR2(4000);
v_msg_num NUMBER(10) := 0;
BEGIN
v_msg_text := 'Procedure executed';
v_msg_num := 1;
END;
/
Script_text_file_01.sql new
BEGIN
DB_USER.PROC_NAME;
END;
/
quit
Since the code is now stored in
the database, the
Script_text_file_01.sql only
contains the call to the
procedure.
Benefits
Compilation
• Most of the code is already compiled – only caller script remains
Memory
• Reduced memory usage
• Faster load
Tracking
• Code can be tracked inside DB
• Explicit dependency – change in related objects are flagged
Reuse
• Code is ready to be reused
• Change in central stored object is immediate for all calling scripts
Security
• Code can be included in database backup/restore
• Access to code restricted by database privileges
Next Steps
Modularization
• Identification of common code for grouping, organization or creation of internal
or even external procedures
• Encapsulation of complex code in procedures of functions
Error Control
• Inclusion of an Exception section for each code block
• Use of user-created exceptions
• Creation of common exception procedures
Best Practices
• Variable initialization
• Eliminate hard-code
And much more …
Training
• Performance Tuning Guide and Reference
 http://docs.oracle.com/cd/B10500_01/server.920/a96533/toc.htm
• SQL Reference
 http://docs.oracle.com/cd/B10500_01/server.920/a96540/toc.htm
• PL/SQL User's Guide and Reference
 http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/toc.htm
Resources at Oracle website
Thank you
Carlos Oliveira / July 23, 2014

Mais conteúdo relacionado

Mais procurados

Architecture Proposition For Multimedia repository
Architecture Proposition For Multimedia repositoryArchitecture Proposition For Multimedia repository
Architecture Proposition For Multimedia repository
McRaken
 
SnapComms Technical Overview
SnapComms Technical OverviewSnapComms Technical Overview
SnapComms Technical Overview
leanne_abarro
 
Highlights of Skills and Experience
Highlights of Skills and ExperienceHighlights of Skills and Experience
Highlights of Skills and Experience
Dave Charlesworth
 
VxClass for Incident Response
VxClass for Incident ResponseVxClass for Incident Response
VxClass for Incident Response
zynamics GmbH
 

Mais procurados (19)

Cqrs.frameworks
Cqrs.frameworksCqrs.frameworks
Cqrs.frameworks
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
CLR Stored Procedures
CLR Stored ProceduresCLR Stored Procedures
CLR Stored Procedures
 
Bottlenecks in Java Applications
Bottlenecks in Java ApplicationsBottlenecks in Java Applications
Bottlenecks in Java Applications
 
Rundeck Office Hours: Best Practices for Access Control Policies
Rundeck Office Hours:  Best Practices for Access Control PoliciesRundeck Office Hours:  Best Practices for Access Control Policies
Rundeck Office Hours: Best Practices for Access Control Policies
 
Architecture Proposition For Multimedia repository
Architecture Proposition For Multimedia repositoryArchitecture Proposition For Multimedia repository
Architecture Proposition For Multimedia repository
 
How to design a distributed system
How to design a distributed systemHow to design a distributed system
How to design a distributed system
 
Comparison between Dynamo and riak
Comparison between Dynamo and riakComparison between Dynamo and riak
Comparison between Dynamo and riak
 
SnapComms Technical Overview
SnapComms Technical OverviewSnapComms Technical Overview
SnapComms Technical Overview
 
005.itsecurity bcp v1
005.itsecurity bcp v1005.itsecurity bcp v1
005.itsecurity bcp v1
 
Redis. Seattle Data Science and Data Engineering Meetup
Redis. Seattle Data Science and Data Engineering MeetupRedis. Seattle Data Science and Data Engineering Meetup
Redis. Seattle Data Science and Data Engineering Meetup
 
Version Control in TFS 2013: GIT - 2013 Application Lifecycle Management Event
Version Control in TFS 2013: GIT - 2013 Application Lifecycle Management EventVersion Control in TFS 2013: GIT - 2013 Application Lifecycle Management Event
Version Control in TFS 2013: GIT - 2013 Application Lifecycle Management Event
 
Highlights of Skills and Experience
Highlights of Skills and ExperienceHighlights of Skills and Experience
Highlights of Skills and Experience
 
Highlights
HighlightsHighlights
Highlights
 
"Building intuitive command-line interfaces in .NET", Alex Thissen
"Building intuitive command-line interfaces in .NET", Alex Thissen"Building intuitive command-line interfaces in .NET", Alex Thissen
"Building intuitive command-line interfaces in .NET", Alex Thissen
 
Linked in
Linked inLinked in
Linked in
 
Dos and Don'ts of Android Application Security (Security Professional Perspec...
Dos and Don'ts of Android Application Security (Security Professional Perspec...Dos and Don'ts of Android Application Security (Security Professional Perspec...
Dos and Don'ts of Android Application Security (Security Professional Perspec...
 
Ride the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database RiderRide the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database Rider
 
VxClass for Incident Response
VxClass for Incident ResponseVxClass for Incident Response
VxClass for Incident Response
 

Destaque (7)

Three phase waveforms rcs
Three phase waveforms   rcsThree phase waveforms   rcs
Three phase waveforms rcs
 
Machado de assis obras
Machado de assis   obrasMachado de assis   obras
Machado de assis obras
 
Machado De Assis
Machado De AssisMachado De Assis
Machado De Assis
 
Eça de Queirós
Eça de QueirósEça de Queirós
Eça de Queirós
 
Eça de Queirós
Eça de QueirósEça de Queirós
Eça de Queirós
 
Machado de Assis
Machado de AssisMachado de Assis
Machado de Assis
 
Os Lusíadas - a estrutura
Os Lusíadas - a estruturaOs Lusíadas - a estrutura
Os Lusíadas - a estrutura
 

Semelhante a Oracle plsql code refactoring - from anonymous block to stored procedure

how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
Anar Godjaev
 
Maruthi_YH_resume
Maruthi_YH_resumeMaruthi_YH_resume
Maruthi_YH_resume
Maruthi YH
 
Hi I need security-related job points for the software develope.docx
Hi I need security-related job points for the software develope.docxHi I need security-related job points for the software develope.docx
Hi I need security-related job points for the software develope.docx
fideladallimore
 
Application hardening
Application hardeningApplication hardening
Application hardening
Jayesh Naik
 

Semelhante a Oracle plsql code refactoring - from anonymous block to stored procedure (20)

Pillars of great Azure Architecture
Pillars of great Azure ArchitecturePillars of great Azure Architecture
Pillars of great Azure Architecture
 
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 
resume_latest
resume_latestresume_latest
resume_latest
 
SQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database ProjectsSQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database Projects
 
Tips_Tricks_for_Oracle_E-Business Suite_Database_Upgrade.pdf
Tips_Tricks_for_Oracle_E-Business Suite_Database_Upgrade.pdfTips_Tricks_for_Oracle_E-Business Suite_Database_Upgrade.pdf
Tips_Tricks_for_Oracle_E-Business Suite_Database_Upgrade.pdf
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
Ow
OwOw
Ow
 
Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
 
Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14
 
Synopsis on online shopping by sudeep singh
Synopsis on online shopping by  sudeep singhSynopsis on online shopping by  sudeep singh
Synopsis on online shopping by sudeep singh
 
Maruthi_YH_resume
Maruthi_YH_resumeMaruthi_YH_resume
Maruthi_YH_resume
 
Hi I need security-related job points for the software develope.docx
Hi I need security-related job points for the software develope.docxHi I need security-related job points for the software develope.docx
Hi I need security-related job points for the software develope.docx
 
Oracle Database Lifecycle Management
Oracle Database Lifecycle ManagementOracle Database Lifecycle Management
Oracle Database Lifecycle Management
 
Whats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product SuiteWhats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product Suite
 
Application hardening, Secure Socket Layer(SSL) & Secure Electronic Transacti...
Application hardening, Secure Socket Layer(SSL) & Secure Electronic Transacti...Application hardening, Secure Socket Layer(SSL) & Secure Electronic Transacti...
Application hardening, Secure Socket Layer(SSL) & Secure Electronic Transacti...
 
Application hardening
Application hardeningApplication hardening
Application hardening
 
Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Oracle plsql code refactoring - from anonymous block to stored procedure

  • 1. Carlos Oliveira / July 23, 2014
  • 2. Agenda  Code Refactoring – From anonymous block to procedure  Introduction  Quote  Code Refactoring  Benefits  Next Steps  Training & Reference  Thank You
  • 3. Introduction I am a forward-looking Information Systems Architect with a solid Oracle DBA background comprising the daily infrastructure tasks of the DBA, several projects as a Data Modeler, and performance management projects. I Started on the mainframe business, and soon had a deep dive in application development for Oracle databases. After acquiring an Oracle certification, I worked on performance enhancement for applications using Oracle databases, and later worked several years as an infrastructure DBA, later I worked on data modeling projects and more recently a performance management project, on both application and database layers.
  • 4. “The limits of my language mean the limits of my world.” Ludwig Wittgenstein
  • 5. Code Refactoring Script_text_file_01.sql – file contents below DECLARE /******************************************************** Description: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Changed: xx/xx/xxxx Changed By: xxxxxxx ********************************************************/ v_msg_text VARCHAR2(4000); v_msg_num NUMBER(10) := 0; BEGIN v_msg_text := 'Procedure executed'; v_msg_num := 1; END; / quit
  • 6. Code Refactoring CREATE OR REPLACE PROCEDURE DB_USER.PROC_NAME IS /******************************************************** Description: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Changed: xx/xx/xxxx Changed By: xxxxxxx ********************************************************/ v_msg_text VARCHAR2(4000); v_msg_num NUMBER(10) := 0; BEGIN v_msg_text := 'Procedure executed'; v_msg_num := 1; END; / Script_text_file_01.sql new BEGIN DB_USER.PROC_NAME; END; / quit Since the code is now stored in the database, the Script_text_file_01.sql only contains the call to the procedure.
  • 7. Benefits Compilation • Most of the code is already compiled – only caller script remains Memory • Reduced memory usage • Faster load Tracking • Code can be tracked inside DB • Explicit dependency – change in related objects are flagged Reuse • Code is ready to be reused • Change in central stored object is immediate for all calling scripts Security • Code can be included in database backup/restore • Access to code restricted by database privileges
  • 8. Next Steps Modularization • Identification of common code for grouping, organization or creation of internal or even external procedures • Encapsulation of complex code in procedures of functions Error Control • Inclusion of an Exception section for each code block • Use of user-created exceptions • Creation of common exception procedures Best Practices • Variable initialization • Eliminate hard-code And much more …
  • 9. Training • Performance Tuning Guide and Reference  http://docs.oracle.com/cd/B10500_01/server.920/a96533/toc.htm • SQL Reference  http://docs.oracle.com/cd/B10500_01/server.920/a96540/toc.htm • PL/SQL User's Guide and Reference  http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/toc.htm Resources at Oracle website
  • 10. Thank you Carlos Oliveira / July 23, 2014