SlideShare a Scribd company logo
1 of 23
Download to read offline
• @sfonplsql
• https://www.youtube.com/channel/PracticallyPerfectPLSQL
• http://stevenfeuersteinonplsql.blogspot.com/
New(er) Stuff in PL/SQL
Steven Feuerstein, Oracle Developer Advocate
1
What’s Included
Autonomous
Database
2 x Databases
20GB Storage Each
Load
Balancing
10 Mbps
Bandwidth
Shape
Storage
2 x 50GB Block
10GB Object
10GB Archive
Compute
2 x VM
1GB Memory
Each
demo
Always Free Database
A Roundup of New PL/SQL Features
18c Qualified expressions for collections and records
Whitelisting with the ACCESSIBLE_BY Clause
More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface
Optimizing Function Execution in SQL
The UTL_CALL_STACK Package
Privileges/Access Management for Program Units
Static Expressions In Place of Literals
Marking elements for deprecation
PL/Scope now includes SQL statements in its analysis
How to get this presentation and code
Go to slideshare.net, search "pl/sql
new stuff". View or download the
presentation.
Code referenced in file names:
download this zip…
http://bit.ly/sfdemofiles
Qualified Expressions (Constructors) for
Associative Arrays and Records
In-line assignment of values to our user-defined types!
Nice improvement in developer productivity and code simplicity
DECLARE
TYPE ints_t IS TABLE OF INTEGER
INDEX BY PLS_INTEGER;
l_ints ints_t := ints_t (
1 => 55, 2 => 555, 3 => 5555);
BEGIN
...
END;
DECLARE
TYPE ints_t IS TABLE OF INTEGER
INDEX BY PLS_INTEGER;
l_ints;
BEGIN
l_ints (1) := 55;
l_ints (2) := 555;
l_ints (3) := 5555;
...
END;
PL/Scope: powerful code analysis tool
This compiler-driven tool collects information about identifiers and
statements, and stores it in data dictionary views.
As of 12.2, this includes analysis of SQL statements inside your PL/SQL
code.
Use PL/Scope to answer questions like:
Where is a variable assigned a value in a program?
Which subprograms call another subprogram?
Which SQL statements appear more than once in my application?
Where do inserts, updates, deletes occur against a specific table?
The ACCESSIBLE_BY Clause 12.1
ACCESSIBLE_BY extends the concept of "privacy" for package
subprograms.
Use it to define a "whitelist" of program units that can invoke a
package's subprograms.
When that public procedure really shouldn’t be used
12c_accessible_by.sql
PACKAGE private_pkg
ACCESSIBLE BY (public_pkg)
IS
PROCEDURE do_this;
PROCEDURE do_that;
END;
PACKAGE BODY public_pkg
IS
PROCEDURE do_only_this
IS
BEGIN
private_pkg.do_this;
private_pkg.do_that;
END;
END;
More PL/SQL-Only Data Types Cross
PL/SQL-to-SQL Interface
Prior to 12c, PL/SQL-only datatypes could not be bound in dynamic
SQL statements, restricted what functions could be called in SQL, etc.
Now, those constraints are greatly relaxed.
Bind records and associative arrays
Use TABLE operator with associative arrays
Can bind Booleans with dynamic PL/SQL, but you cannot bind Booleans into
SQL statements.
TABLE with associative arrays!
12c_table*.sql 12c_bind*.sql
Optimizing Function Execution in SQL
That seems like an awfully good idea!
Two methods:
WITH clause that defines a function
UDF pragma that gives more options to the compiler
WITH FUNCTION: define a function directly within your SQL
statement.
Say goodbye to nasty context switch!
For all those user-defined functions
12c_with_function*.sql 12c_udf*.sql
The UTL_CALL_STACK Package
Prior to 12c, you could obtain several kinds of "stacks" through
individual function calls:
DBMS_UTILITY.FORMAT_CALL_STACK - "How did I get here?"
DBMS_UTILITY.FORMAT_ERROR_STACK - "What is the error
message/stack?"
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE - "On what line was my error
raised?"
Now, the UTL_CALL_STACK package supports all that and a much
better API to the info in the stack.
Improved execution stack granularity and more
12c_utl_call_stack*.sql
Static Expressions In Place of Literals
Static PL/SQL expressions are allowed where only literals were
allowed.
You no longer have to hard-code maximum lengths for VARCHAR2
variables and other data types.
You can even use the built-in ORA_MAX_NAME_LEN for the new
extended name lengths.
No more VARCHAR2(32767)!
IS
my_big_var VARCHAR2 (ORA_MAX_NAME_LEN + 2);
my_qualified_var VARCHAR2 (2 * (ORA_MAX_NAME_LEN +2) + 1);
BEGIN
my_big_var := '"Table_Name";
my_qualified_var := "Schema_Name"."Table_Name";
122_expressions.sql
Goodbye, "Tiny" Name Lengths!
Instead of 30 bytes you can now go all the way up to 128.
But this doesn't mean you should.
Most beneficial for:
Migrations from other databases to Oracle
Multi-byte character sets
Being able to squeak just over that 30 character barrier and no longer having
to compromise readability
Now your identifiers can go on_and_on_and_on_and_on_and_on_and...
122_long_identifiers.sql
Goodbye, Tiny SQL VARCHAR2!
It sure has been irritating that PL/SQL supports VARCHAR2s up to
32K in size (after which , you must switch over to CLOBs), while in
SQL, the maximum was 4000.
Now, SQL's VARCHAR2 and NVARCHAR2 have been extended to 32K
as well!
Note: SQL has these maximum sizes only if the MAX_STRING_SIZE
initialization parameter is set to EXTENDED.
And one more impedance between PL/SQL and SQL
12c_sql_varchar2.sql
Kill Off Old, Dead (should be Zombie) Code.
In 12.2, you can now document via a pragma code that has been
deprecated.
You can then use compile-time warnings to:
identify usages of deprecated code
make it impossible to compile program units that use deprecated code
But don't make PLW-06019 an error. That simply documents the use
of the pragma.
But how do you find it?
CREATE OR REPLACE PACKAGE old_pkg AUTHID DEFINER
AS
PRAGMA DEPRECATE (old_pkg, 'Use new_pkg instead!');
PROCEDURE proc;
END;
Grant Roles to Program Units (back to 12.1)
Grant roles to program units, so you fine-tune the privileges available
to the invoker of a program unit.
Helpful when you don't want the invoker to inherit all of the definer's
privileges.
Roles granted to a program unit do not affect compilation.
Instead, they affect the privilege checking of SQL statements that the unit
issues at run time.
Unit executes with privileges of both its own roles and any other currently
enabled roles.
Nice usability enhancement
12c_grant_role_units.sql 12c_roles_for_program_units.sql
Most helpful when unit executing dynamic SQL
BEQUEATH CURRENT_USER for Views
Prior to 12.1, if your view executed a function, it would always be run
under the privileges of the view's owner, and not that of the function.
Even if the function was defined with AUTHID CURRENT_USER
Add the BEQUEATH CURRENT_USER clause and then the invoker
right's mode of the function will be "honored."
Tying up a loose end
12c_bequeath.sql
INHERIT PRIVILEGES and INHERIT ANY PRIVILEGES
More fine-tuning for privilege management!
You can override AUTHID and BEQUEATH settings by revoking
INHERIT PRIVILEGES.
On a schema-level basis
You can say, in effect: "All schemas but SCOTT can use my privileges
when running X."
After upgrade, all works as before.
INHERT PRIVILEGES granted to all schemas
Yes, there’s more!
12c_inherit_privileges.sql
And is that it?
Support for JSON in PL/SQL via new pre-defined JSON types
Block code coverage
Improvements to DBMS_HPROF, the hierarchical profiler
DBMS_SQL support for PL/SQL types
No, there's more, but there's no more time.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Deepen Your PL/SQL and SQL
Expertise
Take advantage of our community websites.
Oracle AskTOM – https://asktom.oracle.com
Q&A site, Office Hours with database experts, and much more
Oracle Dev Gym – https://devgym.oracle.com
Quizzes, workouts and classes for an active learning experience
Oracle LiveSQL – https://livesql.oracle.com
24x7 access to the latest release of Oracle Database, plus a script library
and tutorials
Questions? Comments?
New(er) Stuff in PL/SQL

More Related Content

What's hot

High Performance Plsql
High Performance PlsqlHigh Performance Plsql
High Performance PlsqlGuy Harrison
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUCAlex Zaballa
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneEnkitec
 
Improving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQLImproving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQLGuatemala User Group
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Developmentrehaniltifat
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015Alex Zaballa
 
Oracle 12c New Features for Developers
Oracle 12c New Features for DevelopersOracle 12c New Features for Developers
Oracle 12c New Features for DevelopersCompleteITProfessional
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gMarcelo Ochoa
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerKevin Kline
 
EM13c: Write Powerful Scripts with EMCLI
EM13c: Write Powerful Scripts with EMCLIEM13c: Write Powerful Scripts with EMCLI
EM13c: Write Powerful Scripts with EMCLIGokhan Atil
 
Best New Features of Oracle Database 12c
Best New Features of Oracle Database 12cBest New Features of Oracle Database 12c
Best New Features of Oracle Database 12cPini Dibask
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
SQL in the Hybrid World
SQL in the Hybrid WorldSQL in the Hybrid World
SQL in the Hybrid WorldTanel Poder
 
Oracle 21c: New Features and Enhancements of Data Pump & TTS
Oracle 21c: New Features and Enhancements of Data Pump & TTSOracle 21c: New Features and Enhancements of Data Pump & TTS
Oracle 21c: New Features and Enhancements of Data Pump & TTSChristian Gohmann
 
Cloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisCloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisYue Chen
 
Performance Management in Oracle 12c
Performance Management in Oracle 12cPerformance Management in Oracle 12c
Performance Management in Oracle 12cAlfredo Krieg
 

What's hot (19)

High Performance Plsql
High Performance PlsqlHigh Performance Plsql
High Performance Plsql
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUC
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
 
Improving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQLImproving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQL
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
 
Oracle 12c New Features for Developers
Oracle 12c New Features for DevelopersOracle 12c New Features for Developers
Oracle 12c New Features for Developers
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11g
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
EM13c: Write Powerful Scripts with EMCLI
EM13c: Write Powerful Scripts with EMCLIEM13c: Write Powerful Scripts with EMCLI
EM13c: Write Powerful Scripts with EMCLI
 
Best New Features of Oracle Database 12c
Best New Features of Oracle Database 12cBest New Features of Oracle Database 12c
Best New Features of Oracle Database 12c
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
SQL in the Hybrid World
SQL in the Hybrid WorldSQL in the Hybrid World
SQL in the Hybrid World
 
Oracle 21c: New Features and Enhancements of Data Pump & TTS
Oracle 21c: New Features and Enhancements of Data Pump & TTSOracle 21c: New Features and Enhancements of Data Pump & TTS
Oracle 21c: New Features and Enhancements of Data Pump & TTS
 
Cloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisCloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and Analysis
 
Performance Management in Oracle 12c
Performance Management in Oracle 12cPerformance Management in Oracle 12c
Performance Management in Oracle 12c
 

Similar to New(er) Stuff in PL/SQL

Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Frederic Descamps
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Frederic Descamps
 
Oracle database 12c intro
Oracle database 12c introOracle database 12c intro
Oracle database 12c intropasalapudi
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionFrederic Descamps
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersSQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersTobias Koprowski
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native -  Why to use MySQL 8.0 and how to use it on oci with MDSCloud native -  Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDSFrederic Descamps
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptxKulbir4
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, proceduresVaibhav Kathuria
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online TrainingOracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Trainingsuresh
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublicKaing Menglieng
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021Frederic Descamps
 
Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Udaykumar Sarana
 

Similar to New(er) Stuff in PL/SQL (20)

Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Oracle database 12c intro
Oracle database 12c introOracle database 12c intro
Oracle database 12c intro
 
Sql Sever Presentation.pptx
Sql Sever Presentation.pptxSql Sever Presentation.pptx
Sql Sever Presentation.pptx
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersSQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native -  Why to use MySQL 8.0 and how to use it on oci with MDSCloud native -  Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Oracle11g notes
Oracle11g notesOracle11g notes
Oracle11g notes
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online TrainingOracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Training
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
 
Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353
 
Sq lite
Sq liteSq lite
Sq lite
 

More from Steven Feuerstein

Six simple steps to unit testing happiness
Six simple steps to unit testing happinessSix simple steps to unit testing happiness
Six simple steps to unit testing happinessSteven Feuerstein
 
Speakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours sessionSpeakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours sessionSteven Feuerstein
 
AskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersAskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersSteven Feuerstein
 
Oracle Application Express and PL/SQL: a world-class combo
Oracle Application Express and PL/SQL: a world-class comboOracle Application Express and PL/SQL: a world-class combo
Oracle Application Express and PL/SQL: a world-class comboSteven Feuerstein
 
Error Management Features of PL/SQL
Error Management Features of PL/SQLError Management Features of PL/SQL
Error Management Features of PL/SQLSteven Feuerstein
 
JSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseJSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseSteven Feuerstein
 
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community SitesOracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community SitesSteven Feuerstein
 
AskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQLAskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQLSteven Feuerstein
 
Database Developers: the most important developers on earth?
Database Developers: the most important developers on earth?Database Developers: the most important developers on earth?
Database Developers: the most important developers on earth?Steven Feuerstein
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreSteven Feuerstein
 
Impact Analysis with PL/Scope
Impact Analysis with PL/ScopeImpact Analysis with PL/Scope
Impact Analysis with PL/ScopeSteven Feuerstein
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL CollectionsSteven Feuerstein
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheSteven Feuerstein
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerSteven Feuerstein
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLSteven Feuerstein
 

More from Steven Feuerstein (18)

Six simple steps to unit testing happiness
Six simple steps to unit testing happinessSix simple steps to unit testing happiness
Six simple steps to unit testing happiness
 
Speakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours sessionSpeakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours session
 
AskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersAskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database Triggers
 
PL/SQL Guilty Pleasures
PL/SQL Guilty PleasuresPL/SQL Guilty Pleasures
PL/SQL Guilty Pleasures
 
Oracle Application Express and PL/SQL: a world-class combo
Oracle Application Express and PL/SQL: a world-class comboOracle Application Express and PL/SQL: a world-class combo
Oracle Application Express and PL/SQL: a world-class combo
 
Error Management Features of PL/SQL
Error Management Features of PL/SQLError Management Features of PL/SQL
Error Management Features of PL/SQL
 
JSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseJSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in Database
 
OLD APEX and PL/SQL
OLD APEX and PL/SQLOLD APEX and PL/SQL
OLD APEX and PL/SQL
 
High Performance PL/SQL
High Performance PL/SQLHigh Performance PL/SQL
High Performance PL/SQL
 
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community SitesOracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
 
AskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQLAskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQL
 
Database Developers: the most important developers on earth?
Database Developers: the most important developers on earth?Database Developers: the most important developers on earth?
Database Developers: the most important developers on earth?
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
 
Impact Analysis with PL/Scope
Impact Analysis with PL/ScopeImpact Analysis with PL/Scope
Impact Analysis with PL/Scope
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result Cache
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL Compiler
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

New(er) Stuff in PL/SQL

  • 1. • @sfonplsql • https://www.youtube.com/channel/PracticallyPerfectPLSQL • http://stevenfeuersteinonplsql.blogspot.com/ New(er) Stuff in PL/SQL Steven Feuerstein, Oracle Developer Advocate 1
  • 2.
  • 3. What’s Included Autonomous Database 2 x Databases 20GB Storage Each Load Balancing 10 Mbps Bandwidth Shape Storage 2 x 50GB Block 10GB Object 10GB Archive Compute 2 x VM 1GB Memory Each demo
  • 5. A Roundup of New PL/SQL Features 18c Qualified expressions for collections and records Whitelisting with the ACCESSIBLE_BY Clause More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface Optimizing Function Execution in SQL The UTL_CALL_STACK Package Privileges/Access Management for Program Units Static Expressions In Place of Literals Marking elements for deprecation PL/Scope now includes SQL statements in its analysis
  • 6. How to get this presentation and code Go to slideshare.net, search "pl/sql new stuff". View or download the presentation. Code referenced in file names: download this zip… http://bit.ly/sfdemofiles
  • 7. Qualified Expressions (Constructors) for Associative Arrays and Records In-line assignment of values to our user-defined types! Nice improvement in developer productivity and code simplicity DECLARE TYPE ints_t IS TABLE OF INTEGER INDEX BY PLS_INTEGER; l_ints ints_t := ints_t ( 1 => 55, 2 => 555, 3 => 5555); BEGIN ... END; DECLARE TYPE ints_t IS TABLE OF INTEGER INDEX BY PLS_INTEGER; l_ints; BEGIN l_ints (1) := 55; l_ints (2) := 555; l_ints (3) := 5555; ... END;
  • 8. PL/Scope: powerful code analysis tool This compiler-driven tool collects information about identifiers and statements, and stores it in data dictionary views. As of 12.2, this includes analysis of SQL statements inside your PL/SQL code. Use PL/Scope to answer questions like: Where is a variable assigned a value in a program? Which subprograms call another subprogram? Which SQL statements appear more than once in my application? Where do inserts, updates, deletes occur against a specific table?
  • 9. The ACCESSIBLE_BY Clause 12.1 ACCESSIBLE_BY extends the concept of "privacy" for package subprograms. Use it to define a "whitelist" of program units that can invoke a package's subprograms. When that public procedure really shouldn’t be used 12c_accessible_by.sql PACKAGE private_pkg ACCESSIBLE BY (public_pkg) IS PROCEDURE do_this; PROCEDURE do_that; END; PACKAGE BODY public_pkg IS PROCEDURE do_only_this IS BEGIN private_pkg.do_this; private_pkg.do_that; END; END;
  • 10. More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface Prior to 12c, PL/SQL-only datatypes could not be bound in dynamic SQL statements, restricted what functions could be called in SQL, etc. Now, those constraints are greatly relaxed. Bind records and associative arrays Use TABLE operator with associative arrays Can bind Booleans with dynamic PL/SQL, but you cannot bind Booleans into SQL statements. TABLE with associative arrays! 12c_table*.sql 12c_bind*.sql
  • 11. Optimizing Function Execution in SQL That seems like an awfully good idea! Two methods: WITH clause that defines a function UDF pragma that gives more options to the compiler WITH FUNCTION: define a function directly within your SQL statement. Say goodbye to nasty context switch! For all those user-defined functions 12c_with_function*.sql 12c_udf*.sql
  • 12. The UTL_CALL_STACK Package Prior to 12c, you could obtain several kinds of "stacks" through individual function calls: DBMS_UTILITY.FORMAT_CALL_STACK - "How did I get here?" DBMS_UTILITY.FORMAT_ERROR_STACK - "What is the error message/stack?" DBMS_UTILITY.FORMAT_ERROR_BACKTRACE - "On what line was my error raised?" Now, the UTL_CALL_STACK package supports all that and a much better API to the info in the stack. Improved execution stack granularity and more 12c_utl_call_stack*.sql
  • 13. Static Expressions In Place of Literals Static PL/SQL expressions are allowed where only literals were allowed. You no longer have to hard-code maximum lengths for VARCHAR2 variables and other data types. You can even use the built-in ORA_MAX_NAME_LEN for the new extended name lengths. No more VARCHAR2(32767)! IS my_big_var VARCHAR2 (ORA_MAX_NAME_LEN + 2); my_qualified_var VARCHAR2 (2 * (ORA_MAX_NAME_LEN +2) + 1); BEGIN my_big_var := '"Table_Name"; my_qualified_var := "Schema_Name"."Table_Name"; 122_expressions.sql
  • 14. Goodbye, "Tiny" Name Lengths! Instead of 30 bytes you can now go all the way up to 128. But this doesn't mean you should. Most beneficial for: Migrations from other databases to Oracle Multi-byte character sets Being able to squeak just over that 30 character barrier and no longer having to compromise readability Now your identifiers can go on_and_on_and_on_and_on_and_on_and... 122_long_identifiers.sql
  • 15. Goodbye, Tiny SQL VARCHAR2! It sure has been irritating that PL/SQL supports VARCHAR2s up to 32K in size (after which , you must switch over to CLOBs), while in SQL, the maximum was 4000. Now, SQL's VARCHAR2 and NVARCHAR2 have been extended to 32K as well! Note: SQL has these maximum sizes only if the MAX_STRING_SIZE initialization parameter is set to EXTENDED. And one more impedance between PL/SQL and SQL 12c_sql_varchar2.sql
  • 16. Kill Off Old, Dead (should be Zombie) Code. In 12.2, you can now document via a pragma code that has been deprecated. You can then use compile-time warnings to: identify usages of deprecated code make it impossible to compile program units that use deprecated code But don't make PLW-06019 an error. That simply documents the use of the pragma. But how do you find it? CREATE OR REPLACE PACKAGE old_pkg AUTHID DEFINER AS PRAGMA DEPRECATE (old_pkg, 'Use new_pkg instead!'); PROCEDURE proc; END;
  • 17. Grant Roles to Program Units (back to 12.1) Grant roles to program units, so you fine-tune the privileges available to the invoker of a program unit. Helpful when you don't want the invoker to inherit all of the definer's privileges. Roles granted to a program unit do not affect compilation. Instead, they affect the privilege checking of SQL statements that the unit issues at run time. Unit executes with privileges of both its own roles and any other currently enabled roles. Nice usability enhancement 12c_grant_role_units.sql 12c_roles_for_program_units.sql Most helpful when unit executing dynamic SQL
  • 18. BEQUEATH CURRENT_USER for Views Prior to 12.1, if your view executed a function, it would always be run under the privileges of the view's owner, and not that of the function. Even if the function was defined with AUTHID CURRENT_USER Add the BEQUEATH CURRENT_USER clause and then the invoker right's mode of the function will be "honored." Tying up a loose end 12c_bequeath.sql
  • 19. INHERIT PRIVILEGES and INHERIT ANY PRIVILEGES More fine-tuning for privilege management! You can override AUTHID and BEQUEATH settings by revoking INHERIT PRIVILEGES. On a schema-level basis You can say, in effect: "All schemas but SCOTT can use my privileges when running X." After upgrade, all works as before. INHERT PRIVILEGES granted to all schemas Yes, there’s more! 12c_inherit_privileges.sql
  • 20. And is that it? Support for JSON in PL/SQL via new pre-defined JSON types Block code coverage Improvements to DBMS_HPROF, the hierarchical profiler DBMS_SQL support for PL/SQL types No, there's more, but there's no more time.
  • 21. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Deepen Your PL/SQL and SQL Expertise Take advantage of our community websites. Oracle AskTOM – https://asktom.oracle.com Q&A site, Office Hours with database experts, and much more Oracle Dev Gym – https://devgym.oracle.com Quizzes, workouts and classes for an active learning experience Oracle LiveSQL – https://livesql.oracle.com 24x7 access to the latest release of Oracle Database, plus a script library and tutorials