Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 1.

Slides:



Advertisements
Similar presentations
1.
Advertisements

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Your customer as a segment of one That changes every second! Hein Van Der Merwe Chief.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Track the changes in your Apex application between releases: Yes you can Plsql.
Chapter 4B: More Advanced PL/SQL Programming
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer What’s New in Version 4.1 Jeff Smith
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 2 Hidden Gems of APEX David Gale Software Engineer Oracle Application Express November,
The Safe Harbor The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Title Slide without Picture Subtitle Presenter’s Name Presenter’s Title Organization,
2 Copyright © 2004, Oracle. All rights reserved. Creating Stored Functions.
Copyright  Oracle Corporation, All rights reserved. 4 Creating Functions.
Oracle PL/SQL Injection David Litchfield. What is PL/SQL? Procedural Language / Structured Query Language Oracle’s extension to standard SQL Programmable.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit The Newest JDE Module – Rental Management Joel Sandberg Sales Consultant.
Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved. | Oracle Identity Management.
Application Express 4.1 New Features Hilary Farrell, Principal Member of Technical Staff, Oracle.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Reporting from Contract.
Oracle E-Business Suite Order Management: Presenting the HTML and Mobile User Experience Durgaprasad Bodapati Director, Product Management Bhavana Sharma.
Oracle PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 6 Virtual Private Databases.
CSIS 4310 – Advanced Databases Virtual Private Databases.
RMB Billing UX Design Concepts / Proposals Peter Picone.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Improving Agility in Product Development and Pricing to Gain a Competitive Edge.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Contract Management.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 7 PL/SQL Packages.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 6 Functions.
PL/SQLPL/SQL Oracle11g : PL/SQL Programming Chapter 6 Functions.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Preview the Plans for JD Edwards World A9.4 Release David Greiner,
Using Procedures & Functions Oracle Database PL/SQL 10g Programming Chapter 9.
Lecture 8 Creating Stored Functions. Objectives  After completing this lesson, you should be able to do the following:  What is Function?  Types of.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Using Edition-based redefinition with PL/SQL How to deploy database code changes.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
1Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Dynamic SQL. 2 home back first prev next last What Will I Learn? Recall the stages through which all SQL statements pass Describe the reasons for using.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Planning & Budgeting Cloud Service (PBCS) Overview Business Analytics Product Group.
Oracle11g: PL/SQL Programming Chapter 3 Handling Data in PL/SQL Blocks.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Chapter 6 Virtual Private Databases
PRACTICE OVERVIEW PL/SQL Part Your stored procedure, GET_BUDGET, has a logic problem and must be modified. The script that contains the procedure.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Oracle9i Developer: PL/SQL Programming Chapter 5 Functions.
Chapter 8 Advanced SQL Pearson Education © Chapter 8 - Objectives How to use the SQL programming language How to use SQL cursors How to create stored.
Travel and Transportation General Session and Industry Excellence Awards Vijay Anand, Oracle Sundar Swaminathan, Oracle September 30, 2014 Copyright ©
SQL Triggers, Functions & Stored Procedures Programming Operations.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 5 Lifehacks for the Apex Development environment Five frameworks you should use.
4 Copyright © 2004, Oracle. All rights reserved. Advanced Interface Methods.
Oracle9i Developer: PL/SQL Programming Chapter 6 PL/SQL Packages.
Preface IIntroduction Course Objectives I-2 Oracle Complete Solution I-3 Course Agenda I-4 Tables Used in This Course I-5 The Order Entry Schema I-6 The.
1 Copyright © 2004, Oracle. All rights reserved. PL/SQL Programming Concepts: Review.
6 Copyright © 2009, Oracle. All rights reserved. Using Dynamic SQL.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What You Need to Know About User Defined Objects (UDOs) With Tools Release 9.2.
Introduction to Triggers
UNIT - V STORED PROCEDURE.
OpenWorld How to Prepare Data from Business Intelligence Cloud Service
Oracle Database Multilingual Engine
PRACTICE OVERVIEW PL/SQL Part - 2.
PRACTICE OVERVIEW PL/SQL Part - 1.
MATERI PL/SQL Procedures Functions Packages Database Triggers
Prof. Arfaoui. COM390 Chapter 7
Presentation transcript:

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 1

Oracle Database 12c Release 1 PL/SQL New Features Steven Feuerstein Architect, Applied PL/SQL

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3 Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 4 Program Agenda  More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface  Optimizing Function Execution in SQL  The UTL_CALL_STACK Package  The ACCESSIBLE_BY Clause  FETCH FIRST and BULK COLLECT

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 5 Program Agenda, continued  Privileges/Access Management for Program Units – Grant Roles to Program Units – And INHERIT PRIVILEGES and INHERIT ANY PRIVILEGES – BEQUEATH CURRENT_USER for Views  New Conditional Compilation Directives  Implicit Statement Results  Goodbye, Tiny SQL VARCHAR2!

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 6 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 rules 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 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql 12c_table*.sql 12c_bind*.sql

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 7 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

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 8 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. Great improvement in execution stack granularity 12c_utl_call_stack*.sql

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 9 FETCH FIRST N for BULK COLLECT  BULK COLLECT now supports an optional FETCH FIRST clause. – Limits the number of rows that a query returns, reducing the complexity of common "Top-N" queries.  FETCH FIRST is provided primarily to simplify migration from third- party databases to Oracle Database. Nice usability enhancement 12c_fetch_first.sql

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 10 The ACCESSIBLE_BY Clause  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;

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 11 Privilege-Related Features  First, let's review definer and invoker rights.  Definer Rights – Whenever you executed a stored program, it runs under the privileges of the schema in which the program was compiled or defined.  Invoker Rights – Oracle resolves all data references (table, view, etc.) at run-time, based on the currently-connect user and its privileges (directly granted or available through roles). Fine-tuning effects of AUTHID clause

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 12 About Definer Rights  Allows you to centralize access to and control of underlying data structures.  Ignores roles and relies on directly-granted privileges.  But it can be a source of confusion and architectural problems. Centralizing control Orders OE Data OE Code Order_Mgt Cancel Sam_Sales Place Close Old Orders X Cannot alter table directly. Note: Oracle built-in packages have long had the capability of running under the invoker's authority.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 13 Drawbacks of Definer Rights  Deployment & maintenance – Must install module in all remote databases where needed – In some databases, each user has own copy of table(s), requiring copy of stored module  Security – No declarative way to restrict privileges on certain modules in a package -- it's all or nothing, unless you write code in the package to essentially recreate roles programmatically. – Difficult to audit privileges  Sure would be nice to have a choice...and you do! Nothing works for everyone

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 14 "Reflection" Capability of Invoker Rights  With invoker rights, you can execute code owned by another schema, yet have all references to data structures "reflect back" into your own schema. User/Data schema accounts table PROCEDURE mng_account IS BEGIN... code.acct_mgr.destroy(...); END; Central Code schema PACKAGE acct_mgr...FROM accounts WHERE... destroy modify make AUTHID CURRENT_USER invdefinv.sql

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 15 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

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 16 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

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 17 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

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 18 New Conditional Compilation Directives  Oracle has added two new directives.  $$PLSQL_UNIT_OWNER – Returns the name of the owner of the current program unit. Returns NULL if an anonymous block.  $$PLSQL_UNIT_TYPE – Returns the type of the program unit – Inside an anonymous block or non-DML trigger, returns "ANONYMOUS BLOCK". For a fantastic and under-utilized feature

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 19 Implicit Statement Results  I hate when a SQL Server developer says "Ha, ha, I can do this and you can't."  Well, with 12.1, there's one less thing that developer can talk about. – Not that there was ever all that much….  We can now create a procedure that will implicitly display the result of a SQL statement. – And it breathes some life back into DBMS_SQL! When you need PL/SQL to act like Transact-SQL 12c_implicit_results.sql

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 20 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  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

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 21 Oracle Database 12c Release 1 PL/SQL  Nothing earth-shattering, but a solid improvement on an already robust language. – Improved integration with SQL – Better support for migration from Transact-SQL and other database languages – Fine-tuning of privileges management and access control.  My favorite by far: ability to use TABLE with associative arrays. Steady improvements, handling new sets of requirements

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 22

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 23