SlideShare a Scribd company logo
PL/SQL & SQL
CODING GUIDELINES – PART 4
Larry Nung
AGENDA
DML and SQL
Reference
Q&A
2
DML AND SQL
26. ALWAYS SPECIFY THE TARGET COLUMNS
WHEN EXECUTING AN INSERT COMMAND.
BAD
INSERT INTO
messages
VALUES
(l_mess_no ,l_mess_typ ,l_mess_text );
GOOD
INSERT INTO
messages
(mess_no ,mess_typ ,mess_text )
VALUES
(l_mess_no ,l_mess_typ ,l_mess_text );
27. ALWAYS USE TABLE ALIASES WHEN YOUR SQL
STATEMENT INVOLVES MORE THAN ONE SOURCE.
GOOD
SELECT
a.pid ,a.name ,a.birthday ,b.country
FROM person a JOIN country b ON (a.cid = b.cid)
WHERE …
28. TRY TO USE ANSI-JOIN SYNTAX, IF
SUPPORTED BY YOUR ORACLE VERSION.
GOOD
SELECT
a.pid ,a.name ,a.birthday ,b.country
FROM person a JOIN country b ON (a.cid = b.cid)
WHERE …
29. TRY TO USE ANCHORED RECORDS AS
TARGETS FOR YOUR CURSORS.
BAD
DECLARE
CURSOR c_user IS
SELECT user_id, firstname, lastname
FROM user;
l_user_id user.user_id%TYPE;
l_firstname user.firstname%TYPE;
l_lastname user.lastname%TYPE;
BEGIN
OPEN c_user;
FETCH c_user INTO l_user_id, l_firstname, l_lastname;
WHILE c_user%FOUND
LOOP
FETCH c_user INTO l_user_id, l_firstname, l_lastname;
END LOOP;
CLOSE c_user;
END;
GOOD
DECLARE
CURSOR c_user IS
SELECT user_id, firstname, lastname
FROM user;
r_user c_user%ROWTYPE;
BEGIN
OPEN c_user;
FETCH c_user INTO r_user;
<<process_user>>
WHILE c_user%FOUND
LOOP
FETCH c_user INTO r_user;
END LOOP process_user;
CLOSE c_user;
END;
DML AND SQL
BULK OPERATIONS
30. USE BULK OPERATIONS (BULK COLLECT,
FORALL) WHENEVER YOU HAVE TO REPEATEDLY
EXECUTE A DML OR SELECT COMMAND FOR
MORE THAN 4 TIMES.
BAD
DECLARE
TYPE t_employee_type IS TABLE OF
emp.empno%TYPE;
t_employees t_employee_type :=
t_employee_type(7369,7698,7839,7844,7876);
BEGIN
FOR i IN 1..t_employees.COUNT()
LOOP
UPDATE emp SET sal = sal * 1.1
WHERE empno = t_employees(i);
END LOOP;
END;
GOOD
DECLARE
TYPE t_employee_type IS TABLE OF
emp.empno%TYPE;
t_employees t_employee_type :=
t_employee_type(7369,7698,7839,7844,7876);
BEGIN
FORALL i IN 1..t_employees.COUNT()
UPDATE emp SET sal = sal * 1.1
WHERE empno = t_employees(i);
END;
REFERENCE
18
REFERENCE
 Trivadis PL/SQL & SQL Coding Guidelines Version
2.0
 http://www.trivadis.com/sites/default/files/downloads/PL
SQL_and_SQL_Coding_Guidelines_2_0_HiRes.pdf
19
Q&A
20
QUESTION & ANSWER
21

More Related Content

Viewers also liked (7)

PDF
Schedulers
Kai Liu
 
PPTX
PL/SQL & SQL CODING GUIDELINES – Part 5
Larry Nung
 
PPT
Oracle pl/sql control statments
Tayba Bashir
 
PDF
Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...
Raj Lal
 
PDF
Characteristics of a well designed user interface
Thomas Byttebier
 
PPTX
End User Computing
Mudit Dhebar
 
PPTX
Presentación1
citlaliaguirre
 
Schedulers
Kai Liu
 
PL/SQL & SQL CODING GUIDELINES – Part 5
Larry Nung
 
Oracle pl/sql control statments
Tayba Bashir
 
Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...
Raj Lal
 
Characteristics of a well designed user interface
Thomas Byttebier
 
End User Computing
Mudit Dhebar
 
Presentación1
citlaliaguirre
 

Similar to PL/SQL & SQL CODING GUIDELINES – Part 4 (20)

PDF
Oracle 11G Development Training noida Delhi NCR
Shri Prakash Pandey
 
PDF
Oracle11gdevtrainingindelhincr
ducat1989
 
DOC
Oracle 11g sql plsql training
FuturePoint Technologies
 
PPT
L9 l10 server side programming
Rushdi Shams
 
PDF
Basics of SELECT Statement - Oracle SQL
MuhammadWaheed44
 
PPTX
PL_SQL_1.pptx fvbxcfbhxdfgh .
RAMIROENRIQUERAMALLO
 
PPTX
PL/SQL Coding Guidelines - Part 1
Larry Nung
 
PDF
Pl sql student guide v 1
Nexus
 
DOCX
Oracle Fundamental and PL-SQL.docx
Chandan Kumar
 
PPT
Ppt on plssql study aboutnsmsmskskwkwkwkwk
DrStrange634619
 
PPT
oracle plsql training | oracle online training | oracle plsql demo | oracle p...
Nancy Thomas
 
PPT
10gplsqlslide-120704232925-phJKKJJKKJpapp01.ppt
Noorien3
 
PPTX
PL/SQL Fundamentals I
Nick Buytaert
 
PPT
SQL / PL
srijanani2030
 
PPTX
pl/sql online Training|sql online Training | iTeknowledge
Masood Khan
 
PPT
SQL- Introduction to PL/SQL
Vibrant Technologies & Computers
 
PPTX
BBarters_PL_SQL gives cdemo details.pptx
shailesh patil
 
PPTX
Ch as pbdasdadssadsadsadasdasdasdas fdt .pptx
sharmilasatishpore
 
PPTX
PL/SQL Coding Guidelines - Part 3
Larry Nung
 
Oracle 11G Development Training noida Delhi NCR
Shri Prakash Pandey
 
Oracle11gdevtrainingindelhincr
ducat1989
 
Oracle 11g sql plsql training
FuturePoint Technologies
 
L9 l10 server side programming
Rushdi Shams
 
Basics of SELECT Statement - Oracle SQL
MuhammadWaheed44
 
PL_SQL_1.pptx fvbxcfbhxdfgh .
RAMIROENRIQUERAMALLO
 
PL/SQL Coding Guidelines - Part 1
Larry Nung
 
Pl sql student guide v 1
Nexus
 
Oracle Fundamental and PL-SQL.docx
Chandan Kumar
 
Ppt on plssql study aboutnsmsmskskwkwkwkwk
DrStrange634619
 
oracle plsql training | oracle online training | oracle plsql demo | oracle p...
Nancy Thomas
 
10gplsqlslide-120704232925-phJKKJJKKJpapp01.ppt
Noorien3
 
PL/SQL Fundamentals I
Nick Buytaert
 
SQL / PL
srijanani2030
 
pl/sql online Training|sql online Training | iTeknowledge
Masood Khan
 
SQL- Introduction to PL/SQL
Vibrant Technologies & Computers
 
BBarters_PL_SQL gives cdemo details.pptx
shailesh patil
 
Ch as pbdasdadssadsadsadasdasdasdas fdt .pptx
sharmilasatishpore
 
PL/SQL Coding Guidelines - Part 3
Larry Nung
 
Ad

More from Larry Nung (20)

PPTX
Ansible - simple it automation
Larry Nung
 
PPTX
sonarwhal - a linting tool for the web
Larry Nung
 
PPTX
LiteDB - A .NET NoSQL Document Store in a single data file
Larry Nung
 
PPTX
PL/SQL & SQL CODING GUIDELINES – Part 8
Larry Nung
 
PPTX
MessagePack - An efficient binary serialization format
Larry Nung
 
PPTX
PL/SQL & SQL CODING GUIDELINES – Part 7
Larry Nung
 
PPTX
BenchmarkDotNet - Powerful .NET library for benchmarking
Larry Nung
 
PPTX
PLSQL Coding Guidelines - Part 6
Larry Nung
 
PPTX
SonarQube - The leading platform for Continuous Code Quality
Larry Nung
 
PPTX
Visual studio 2017
Larry Nung
 
PPTX
Web deploy command line
Larry Nung
 
PPTX
Web deploy
Larry Nung
 
PPTX
SikuliX
Larry Nung
 
PPTX
Topshelf - An easy service hosting framework for building Windows services us...
Larry Nung
 
PPTX
Common.logging
Larry Nung
 
PPTX
protobuf-net - Protocol Buffers library for idiomatic .NET
Larry Nung
 
PPTX
Regular expression
Larry Nung
 
PPTX
Fx.configuration
Larry Nung
 
PPTX
StackExchange.redis
Larry Nung
 
PPTX
Disruptor
Larry Nung
 
Ansible - simple it automation
Larry Nung
 
sonarwhal - a linting tool for the web
Larry Nung
 
LiteDB - A .NET NoSQL Document Store in a single data file
Larry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 8
Larry Nung
 
MessagePack - An efficient binary serialization format
Larry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 7
Larry Nung
 
BenchmarkDotNet - Powerful .NET library for benchmarking
Larry Nung
 
PLSQL Coding Guidelines - Part 6
Larry Nung
 
SonarQube - The leading platform for Continuous Code Quality
Larry Nung
 
Visual studio 2017
Larry Nung
 
Web deploy command line
Larry Nung
 
Web deploy
Larry Nung
 
SikuliX
Larry Nung
 
Topshelf - An easy service hosting framework for building Windows services us...
Larry Nung
 
Common.logging
Larry Nung
 
protobuf-net - Protocol Buffers library for idiomatic .NET
Larry Nung
 
Regular expression
Larry Nung
 
Fx.configuration
Larry Nung
 
StackExchange.redis
Larry Nung
 
Disruptor
Larry Nung
 
Ad

Recently uploaded (20)

PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 

PL/SQL & SQL CODING GUIDELINES – Part 4