0% found this document useful (0 votes)
57 views

Top Ten List: Oracle 11g PL/SQL Features and Enhancements

The document is a presentation on the top 10 new features in Oracle 11g PL/SQL. It discusses each feature in order, providing examples of how they simplify development, improve performance and usability. The top feature is native compilation of PL/SQL code, which improves performance by compiling code into the database rather than interpreting. Other major features include edition-based redefinition for seamless upgrades, hierarchical profiling for performance tuning, and native database web services.

Uploaded by

marcoavellino
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Top Ten List: Oracle 11g PL/SQL Features and Enhancements

The document is a presentation on the top 10 new features in Oracle 11g PL/SQL. It discusses each feature in order, providing examples of how they simplify development, improve performance and usability. The top feature is native compilation of PL/SQL code, which improves performance by compiling code into the database rather than interpreting. Other major features include edition-based redefinition for seamless upgrades, hierarchical profiling for performance tuning, and native database web services.

Uploaded by

marcoavellino
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Top Ten List

Oracle 11g PL/SQL Features and Enhancements Rick Michaud Senior Sales Consultant Oracle Corporation
1
Wednesday, May 5, 2010 1

Who Am I?
Senior Sales Consultant for Oracle for the last 3 years. 20 years as an architect, developer and DBA. My last name is pronounced Me Show

Wednesday, May 5, 2010

Complex Agenda

Introduction Top Ten List Q&A

Wednesday, May 5, 2010

Introduction

Wednesday, May 5, 2010

Oracle Features Added by Release


Release 1 700 525 350 175 0 Oracle 7 Oracle 8i Oracle 10g Release 2

Wednesday, May 5, 2010

11g PL/SQL Feature Focus


1. Simplifying database PL/SQL development 2. Improving usability 3. Enhancing performance 4. Providing functionality and tools to do the above!

Wednesday, May 5, 2010

Top Ten List

Wednesday, May 5, 2010

#10
Simplified Sequence Expressions

8
Wednesday, May 5, 2010 8

#10 Simplied Sequence Expressions


Was there any real useful reason for the Dual table? Can now use sequence expression whenever there is a numeric expression. Before 11gR1:
DECLARE v BINARY_INTEGER; w BINARY_INTEGER; BEGIN SELECT MY_SEQ.NEXTVAL INTO v FROM DUAL; SELECT MY_SEQ.CURRVAL INTO w FROM DUAL; END;

After 11gR2:
DECLARE v BINARY_INTEGER; BEGIN v := MY_SEQ.NEXTVAL; w := MY_SEQ.CURRVAL; END;

11gR1 9

Wednesday, May 5, 2010

#9
Fine-Grained Dependency Tracking

10
Wednesday, May 5, 2010 10

#9 Fine-Grained Dependency Tracking


Prior to 11g: ORA-4068:Existing State of packages has been discarded or invalidated Invalid views until queried Recompile Loop: UTL_RECOMP... SELECT COUNT(*) FROM DBA_OBJECTS WHERE STATUS=INVALID With 11g: Dependencies tracked at code level 11gR2 - now adds support for triggers! Can still get ORA-4068, but has been reduced.
11
Wednesday, May 5, 2010 11

11gR1

#8
Named and Mixed Notation

12
Wednesday, May 5, 2010 12

#8 Named and Mixed Notation User Functions in SQL


Given:
FUNCTION f( p1 IN INTEGER := 1, p2 IN INTEGER := 2, ... pn IN INTEGER := 99) RETURN INTEGER

Can now do:


SELECT f(1, pn=>3) FROM dual

Instead of:
SELECT f(pn=>3, p2=>2, p1=>1) FROM dual

11gR1 13
Wednesday, May 5, 2010 13

#7
DBFS Content API

14
Wednesday, May 5, 2010 14

DBFS and the DBFS Content API


DBFS is a posix compliant le system built on top of the database Why do this? Allows unstructured content to be managed with relational content High performance solution for parallel ETL (e.g. Staging Files) Security and data Data load for Database Machine (aka Exadata) DBFS Content API allows interaction with lesystem at a PL/SQL programmatic level. Great for data manufacturing/ production.

11gR2 15

Wednesday, May 5, 2010

15

DBFS Content API Example


connect foo/****** declare ret integer; b blob; str varchar2(1000) := '' || chr(10) || '#include <stdio.h>' || chr(10) || '' || chr(10) || 'int main(int argc, char** argv)' || chr(10) || '{' || chr(10) || ' (void) printf("hello world\n");' || chr(10) || ' return 0;' || chr(10) || '}' || chr(10) || ''; begin ret := dbms_fuse.fs_mkdir('/mnt1/src'); ret := dbms_fuse.fs_creat('/mnt1/src/hello.c', content => b); dbms_lob.writeappend(b, length(str), utl_raw.cast_to_raw(str)); commit; end; / show errors; -- verify newly created directory and file select pathname, pathtype, length(filedata), utl_raw.cast_to_varchar2(filedata) from dbfs_content where pathname like '/mnt1/src%' order by pathname;

Wednesday, May 5, 2010

16

#6
PL/SQL Subprogram Inlining

17
Wednesday, May 5, 2010 17

#6: PL/SQL Subprogram Inlining


Performance enhancement feature to alleviate overhead of subprogram calls. Replaces a subprogram invocation with a copy of the invoked subprogram. Used for small frequently-used subprograms. Similar to inlining in C Can be enabled with the following: Automatic: Init.ora parameter: PLSQL_OPTIMIZE_LEVEL = 3) Manual: PRAGMA INLINE (Must have PLSQL_OPTIMIZE_LEVEL = 2) Will improve performance in the majority of cases, however: Remember to test performance to measure impacts Make sure you use only on small, frequently used subprograms. Disable when debugging code.
18
Wednesday, May 5, 2010 18

11gR1

#5
PL/Scope

19
Wednesday, May 5, 2010 19

#5 PL/Scope
Developer productivity tool that enables navigation of code by named tags Useful for analyzing: Impact of code changes beforehand Inherited code from a developer who didnt believe in documentation. Similar to c-scope for C Developers Data For PL/SQL program units generated at compile time and stored in data dictionary Tooling available in SQL Developer
20
Wednesday, May 5, 2010 20

11gR1

#4
PL/SQL Hierarchical Profiler

21
Wednesday, May 5, 2010 21

#4 PL/SQL Hierarchical Proler


Identies bottlenecks and performance issues in PL/SQL applications Reports the dynamic execution prole of the PL/SQL program organized by subprogram calls. Requires no special source or compile time preparation. Stores results in hierarchical proler tables. Provides information such as: Number of calls to subprogram Time spent in subprogram Time spent in descendant subprograms Callers of a given subprogram All called subprograms of a particular subprogram
22
Wednesday, May 5, 2010 22

11gR1

#4 PL/SQL Hierarchical Proler


How to run manually: 1. 2. 3. 4. 5. 6. Grant execute on DBMS_HPROF. Setup directory for traceles via CREATE DIRECTORY Start proling. Call your subprogram. Stop proling. Analyze results: 1. 2. 3. 4. Review raw trace le. Using DBMS_HPROF.ANALYZE* Using plshprof utility to generate HTML Report * Requires Data Dictionary tables to be created with dbmshptab.sql
CREATE DIRECTORY PLSHPROF_DIR as '/private/plshprof/ results'; GRANT READ, WRITE ON DIRECTORY PLSHPROF_DIR TO HR; GRANT EXCUTE on DBMS_HPROF to HR; BEGIN /* Start profiling. Write raw profiler output to file test.trc in a directory that is mapped to directory object PLSHPROF_DIR (see note following example). */ DBMS_HPROF.START_PROFILING('PLSHPROF_DIR', 'test.trc'); END; / -- Execute procedure to be profiled BEGIN test; END; / BEGIN -- Stop profiling DBMS_HPROF.STOP_PROFILING; END; /

Tooling available through SQLDeveloper 2.0!

Wednesday, May 5, 2010

23

#3
Edition-based Redefinition

24
Wednesday, May 5, 2010 24

#3 Edition-Based Redenition
Enables application developers to upgrade objects while in use Reduces system downtime Enables seamless application upgrades Data changes are possible through cross-edition triggers. Supported objects:
Synonym Function Package Specication Type Specication Library View Procedure Package Body Type Body Trigger

11gR2

25
Wednesday, May 5, 2010 25

Simple Example
CREATE OR REPLACE FUNCTION NORMALIZED_NAME (FIRST_NAME IN VARCHAR2, LAST_NAME IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN FIRST_NAME || ' ' || LAST_NAME; END NORMALIZED_NAME; / DECLARE v_Return VARCHAR2(200); BEGIN v_Return := NORMALIZED_NAME('john','doe); DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return); END; / >>v_Return = john doe CREATE EDITION patch_normalized_name_1; ALTER SESSION SET EDITION = patch_normalized_name_1; CREATE OR REPLACE FUNCTION NORMALIZED_NAME (FIRST_NAME IN VARCHAR2, LAST_NAME IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN INITCAP(LAST_NAME) || ', ' || INITCAP(FIRST_NAME); END NORMALIZED_NAME; / DECLARE v_Return VARCHAR2(200); BEGIN v_Return := NORMALIZED_NAME('john','doe'); DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return); END; / >>v_Return = Doe, John ALTER SESSION SET EDITION = ora$base;; DECLARE v_Return VARCHAR2(200); BEGIN v_Return := NORMALIZED_NAME('john','doe); DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return); END; / >>v_Return = john doe

Wednesday, May 5, 2010

26

#2
Native Database Web Services

27
Wednesday, May 5, 2010 27

#2 Native Database Web Services


Easily expose functionality in Database as a web service PL/SQL packages, procedures, functions SQL Queries XQuery No need for app server Uses a servlet architecture on XDB HTTP Server Can be secured by integrated with a WS-Security provider
28
Wednesday, May 5, 2010 28

11gR1

#1
PL/SQL Native Compiler

29
Wednesday, May 5, 2010 29

PL/SQL Native Compilation


Useful feature for PL/SQL performance improvement Especially computational code Great for DW server-side transformations Released in 9i Required platform native compiler to be installed. Was cumbersome to congure and setup Sometimes this wasnt allowed -- e.g. PRODUCTION!! 11g compiler is built-in Doesnt require a 3rd party compiler No DLLs generated, compiled code stored in database catalog Gotchas: Not available on all platforms For those 10g Native Compilation option is still available For debugging processes, stick with interpreted code as compiling takes time

11gR1

30
Wednesday, May 5, 2010 30

And a few more...


Sorry I couldnt help myself!

31
Wednesday, May 5, 2010 31

And a few more...


Pipelined Table Functions Loop CONTINUE Statement Simple Types: SIMPLE_FLOAT SIMPLE_INTEGER SIMPLE_DOUBLE PL/SQL Function Result Cache More control over Triggers: ENABLE DISABLE FOLLOWS IGNORE_ROW_ON_DUPKEY_INDEX hint Analytic Functions 2.0 DBMS_PARALLEL_EXECUTE package Scheduler Improvements: File Watcher Email Notication Remote Database Jobs XStream API XML DB Improvements Binary XML XDB Repository Improvements XMLIndex Improvements XMLType Partitioning

32
Wednesday, May 5, 2010 32

Burning Questions?

33
Wednesday, May 5, 2010 33

For more information


Oracle Home Page: http://www.oracle.com Oracle Technology Network: http://otn.oracle.com Oracle Search: http://search.oracle.com Oracle Iron Man 2 Information: http://www.oracle.com/us/ironman2/index.html

Wednesday, May 5, 2010

34

You might also like