PL/SQL: It’s all in the presentation! Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g, 11g)

Slides:



Advertisements
Similar presentations
PL/SQL : Stop making the same performance mistakes
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
SFDC Integration Basics Gerry Winning. Integrating Your Progress App with SFDC Ovid Back Office App is Fully Integrated with SFDC (about two and a half.
Spring, Hibernate and Web Services 13 th September 2014.
Inside Data Access with SQLXML: Architecture Guide Rolandas Gricius MCT, MCSE, MCSD Adapted From.
T Sponsors Sameer Chabungbam Principal Program Manager, Microsoft Connector API Apps BizTalk Summit 2015 – London ExCeL London | April 13th & 14th.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 42 Web Services.
Peoplesoft: Building and Consuming Web Services
Microsoft ® Official Course Interacting with the Search Service Microsoft SharePoint 2013 SharePoint Practice.
4/25/ Application Server Issues for the Project CSEP 545 Transaction Processing for E-Commerce Philip A. Bernstein Copyright ©2003 Philip A. Bernstein.
Service Broker Lesson 11. Skills Matrix Service Broker Service Broker, provides a solution to common problems with message delivery and consistency that.
Oracle Developer Tools for Visual Studio.NET Christian Shay Principal Product Manager Oracle Corporation Prerequisites for presentation:
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group.
The powerhouse PL/SQL upgrade option: Edition-Based Redefinition (EBR)
“This presentation is for informational purposes only and may not be incorporated into a contract or agreement.”
Configuration Management and Server Administration Mohan Bang Endeca Server.
Native Support for Web Services  Native Web services access  Enables cross platform interoperability  Reduces middle-tier dependency (no IIS)  Simplifies.
Oracle9 i JDeveloper for Database Developers and DBAs Brian Fry Principal Product Manager Oracle JDeveloper Oracle Corporation.
DICOM / HL7 Verfication / Java Basis Random user with no account justs wants to validate an HL7 message or DICOM object The next diagram shows a number.
IAM Online - Grouper Permissions Chris Hyzer University of Pennsylvania / Internet2 September 14, /14/20151.
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Presenting Statistical Data Using XML Office for National Statistics, United Kingdom Rob Hawkins, Application Development.
M1G Introduction to Database Development 6. Building Applications.
J2EE Structure & Definitions Catie Welsh CSE 432
CSCI 6962: Server-side Design and Programming Web Services.
Tom Castiglia Hershey Technologies
Lecture 15 Introduction to Web Services Web Service Applications.
Oracle Application Express Security. © 2009 Oracle Corporation Authentication Out-of-the-Box Pre-Configured Schemes LDAP Directory credentials Oracle.
Flex Data Communications Nick Kwiatkowski, Michigan State University.
1.NET Web Forms Web Services © 2002 by Jerry Post.
CYBORG Domain Independent Distributed Database Retrieval System Alok Khemka Kapil Assudani Kedar Fondekar Rahul Nabar.
From Zero to Hero : Using an assortment of caching techniques to improve performance of SQL containing PL/SQL calls. Tim Hall.
Nadir Saghar, Tony Pan, Ashish Sharma REST for Data Services.
(VPD) Virtual Private Database Technique Hessah Hassan Al_kaoud.
Wrapping Scientific Applications As Web Services Using The Opal Toolkit Wrapping Scientific Applications As Web Services Using The Opal Toolkit Sriram.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
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,
INT-9: Implementing ESB Processes with OpenEdge ® and Sonic ™ David Cleary Principal Software Engineer.
Kemal Baykal Rasim Ismayilov
Developing Web Services with the Eclipse Web Tools Platform David Gallardo.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Session id: Darrell Hilliard Senior Delivery Manager Oracle University Oracle Corporation.
PL/SQL programming Procedures and Cursors Lecture 1 [Part 2]
Introduction Because database applications today reside in a complicated environment, various standards have been developed for accessing database servers.
Endpoints Lesson 17. Skills Matrix Endpoints Endpoints provide a reliable, securable, scalable messaging system that enables SQL Server to communicate.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
1 ECHO ECHO 9.0 for Data Partners Rob Baker January 23, 2007.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
Excel Services Displays all or parts of interactive Excel worksheets in the browser –Excel “publish” feature with optional parameters defined in worksheet.
Caching for PL/SQL Performance Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCA.
THE API AN INTRODUCTION TO THE MINISTRYPLATFORM APPLICATION PROGRAMMING INTERFACE STEPHEN WAREHAM.
SAP Integration with Oracle 11g Muhammad Raza Fatmi.
6. Application Server Issues for the Project
Java Web Services Orca Knowledge Center – Web Service key concepts.
Tim Hall Oracle ACE Director
DEPTT. OF COMP. SC & APPLICATIONS
Managing State Chapter 13.
Sabri Kızanlık Ural Emekçi
WEB SERVICES.
Unit – 5 JAVA Web Services
UNIT - V STORED PROCEDURE.
The powerhouse PL/SQL upgrade option: Edition-Based Redefinition (EBR)
WEB API.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Testing RESTful Web APIs
Опит в използването на ODP.NET с Oracle 9i
Chapter 10 ADO.
Chapter 42 Web Services.
PHP Forms and Databases.
Consuming Web Services with 2E Generated Objects
Presentation transcript:

PL/SQL: It’s all in the presentation! Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCA PL/SQL Developer Oracle PL/SQL Tuning (Rampant) Oracle Job Scheduling (Rampant)

PL/SQL: It’s all in the presentation! Physical organization of objectsPhysical organization of objects Present queries from APIsPresent queries from APIs –Ref cursors –Table functions and pipelining Presenting data as web services and XMLPresenting data as web services and XML –SOAP web services –XML over HTTP –REST web services

Physical organization of objects Schema Owner API Owner Login User PL/SQL APIs Views? Tables APEXPHP.NETJava

Physical organization of objects Schema Owner API Owner Login User PL/SQL APIs Tables APEXPHP.NETJava API Owner Login User

Why break things up like this? All data access via presentation (API) layer.All data access via presentation (API) layer. –Better security. –Hides processing complexity from clients. –Presentation layer is sharable between applications. –Easier to tune and trace. –Hides schema changes from client applications. Table or Transactional APIs?Table or Transactional APIs? –Transactional APIs are important to me. APIs that perform business functions and and are understandable by the business. –I feel table APIs are unnecessary, but if you like them use them. –Don’t present table APIs to the outside world.

How do we implement it? Use existing techniques to abstract the data:Use existing techniques to abstract the data: –Packaged procedures and functions for data processing. –Ref cursors and pipelined table functions for data presentation. schema_setup.sqlschema_setup.sqlschema_setup.sql

Without using APIs basic_query.php

Do views help? Views do reduce complexity of code in client apps.Views do reduce complexity of code in client apps. I prefer not to expose views to client developers.I prefer not to expose views to client developers. Risk of client developers writing joins between views.Risk of client developers writing joins between views. How would a view affect the previous client code?How would a view affect the previous client code? web_view.sql

Using a view view_query.php

Cursor variables (REF CURSOR) What are they?What are they? –A pointer to current row in multi-row query. Why are they useful?Why are they useful? –Allow us to separate opening and processing of cursors. –Can be passed as parameters. Why is that useful to us?Why is that useful to us? –Allows us to pass resultsets to client applications Is that all they can do?Is that all they can do? –No, but it gets boring pretty fast… Do we have to define REF CURSOR types?Do we have to define REF CURSOR types? –No. We can be lazy and use SYS_REFCURSOR type.

Returning a cursor from a function web_rc_api.sql

Using ref cursors rc_query.php

I don’t have a simple query. What so I do? You could use a table function.You could use a table function. What’s one of those?What’s one of those? –Functions that return collections are known as table functions. How can that help me?How can that help me? –In combination with the TABLE function, they can be used in the FROM clause of a query like a regular table. tf_test.sql tf_test.sql For regular table functions, the collection must be defined using database OBJECT types.For regular table functions, the collection must be defined using database OBJECT types. Is that all I need to know?Is that all I need to know? –Not really. You need to know about pipelining.

Pipelining table functions A table function builds the entire collection before returning any data, while a pipelined table function “pipes” each row out as soon as it is created.A table function builds the entire collection before returning any data, while a pipelined table function “pipes” each row out as soon as it is created. How does that help me?How does that help me? –It reduces first row lag… ptf_schema.sql, ptf_package.sql, ptf_query.sql ptf_schema.sqlptf_package.sqlptf_query.sql ptf_schema.sqlptf_package.sqlptf_query.sql –As the collection is never fully resident in memory, pipelining can produce a considerable memory saving. memory_usage.sql memory_usage.sql –Since 9i R2, the types used to define the pipelined table function can be defined in a package, but this method can produce management problems, so I prefer the explicit method. implicit_types.sql implicit_types.sql But how does that really help me?But how does that really help me? –You can use PL/SQL to build the row then pass it out.

Defining a Pipelined table Function web_ptf_api.sql

Using a pipelined table function ptf_query.php

Can we improve on this? We can combine Pipelined Table Functions and Ref Cursors. web_rc_ptf_api.sqlWe can combine Pipelined Table Functions and Ref Cursors. web_rc_ptf_api.sql web_rc_ptf_api.sql How will that affect the client code?How will that affect the client code?

RC & PTF together (rc_ptf_query.php) rc_ptf_query.php

What have we shown? We can use APIs to hide complexity from client application developers.We can use APIs to hide complexity from client application developers. How do we present queries from our APIs?How do we present queries from our APIs? –Ref cursors –Pipelined table functions –Views? Remember: The technology dictates will and won’t want to do with APIs, not just our ideals.Remember: The technology dictates will and won’t want to do with APIs, not just our ideals. Is that the only way we can present data from PL/SQL?Is that the only way we can present data from PL/SQL? –Certainly not…

Web Services and XML eGov AU: Craig Thomler's personal eGovernment and Gov 2.0 thoughts and speculations from an Australian perspectiveeGov AU: Craig Thomler's personal eGovernment and Gov 2.0 thoughts and speculations from an Australian perspective Overcoming public sector hurdles to Gov public sector hurdles to Gov Choice quotes:Choice quotes: –"...people are generally most comfortable with the technologies they grew up with...” –"...government systems are struggling in some areas to keep up with the rate of change...” –"If our systems can't support Gov 2.0 initiatives then it is unlikely that our senior management will.”

Web Services and XML What does this have to do with PL/SQL?What does this have to do with PL/SQL? –PL/SQL allows you to create web applications, without the learning curve of Java or.NET. –Oracle allows you to present existing PL/SQL code as web services with zero effort. –Oracle's web toolkit allows you to present data as XML really easily. –PL/SQL is mature, not legacy.

XML DB Native Web Services Oracle XML DB Native Web Services present your PL/SQL as Simple Object Access Protocol (SOAP) web services.Oracle XML DB Native Web Services present your PL/SQL as Simple Object Access Protocol (SOAP) web services. Requires a single configuration step on the database.Requires a single configuration step on the database. Enabled for “schema” by granting:Enabled for “schema” by granting: –GRANT XDB_WEBSERVICES TO user; Optionally:Optionally: –GRANT XDB_WEBSERVICES_OVER_HTTP TO user; –GRANT XDB_WEBSERVICES_WITH_PUBLIC TO user; --? web_services_setup.sqlweb_services_setup.sqlweb_services_setup.sql XML DB auto-generates a WSDL file.XML DB auto-generates a WSDL file.WSDL We send a SOAP Request and get a SOAP Response returned.We send a SOAP Request and get a SOAP Response returned.SOAP RequestSOAP ResponseSOAP RequestSOAP Response call_ws.pl (run it)call_ws.pl (run it)call_ws.plrun itcall_ws.plrun it Physical organization of schema keeps things neat.Physical organization of schema keeps things neat.

Physical organization of objects Schema Owner WS API Owner PL/SQL APIs Tables.NETJavaAPEX API Owner Login User

XML over HTTP We can also present XML directly from the database.We can also present XML directly from the database. First we define a Database Access Descriptor (DAD) to give a “schema” access to the web toolkit functionality. xml_api_setup.sqlFirst we define a Database Access Descriptor (DAD) to give a “schema” access to the web toolkit functionality. xml_api_setup.sql xml_api_setup.sql Next we define a package to generate our XML. xml_api.sql (run it)Next we define a package to generate our XML. xml_api.sql (run it) xml_api.sqlrun it xml_api.sqlrun it This is an incredibly simple way to get XML out of the database.This is an incredibly simple way to get XML out of the database. Once again, physical organization is important.Once again, physical organization is important.

XML over HTTP (Semi-Static Data) The previous method regenerates the XML each time the URL is called.The previous method regenerates the XML each time the URL is called. For semi-static data this is a waste of resources.For semi-static data this is a waste of resources. Solution? Generate once and re-present.Solution? Generate once and re-present. How? Place it in the XML DB file system. xml_db_setup.sqlHow? Place it in the XML DB file system. xml_db_setup.sql xml_db_setup.sql Next we define a procedure to generate our XML. semi_static.sqlNext we define a procedure to generate our XML. semi_static.sql semi_static.sql How do we access this file? HTTP, FTP access, WebDAVHow do we access this file? HTTP, FTP access, WebDAV HTTP This can reduce resource usages.This can reduce resource usages.

REST web services The previous method is similar to Representational State Transfer (REST) web services, with the exception of the URL.The previous method is similar to Representational State Transfer (REST) web services, with the exception of the URL. We can mimic REST web services using the EPG parameters:We can mimic REST web services using the EPG parameters: –PATH-ALIAS –PATH-ALIAS-PROCEDURE rest_api_setup.sqlrest_api_setup.sqlrest_api_setup.sql rest_api.sqlrest_api.sqlrest_api.sql REST DemoREST DemoREST DemoREST Demo We can easily code REST web services directly from PL/SQL.We can easily code REST web services directly from PL/SQL.

Summary Physical organization of objectsPhysical organization of objects –Important for us to present business driven functionality. Ref cursorsRef cursors –Allows us to hide complexity from client applications. Table functionsTable functions –Allow us to return complex data as if it were a simple query. Presenting data as web services and XML is easy using PL/SQLPresenting data as web services and XML is easy using PL/SQL –Presenting existing PL/SQL code as SOAP web services. –Producing REST web services from PL/SQL. Which all keeps us relevant in the new world order.Which all keeps us relevant in the new world order. Demo Code: Code: