SlideShare ist ein Scribd-Unternehmen logo
1 von 69
XML Programming in PL/SQL (Part 1)“An Introduction to the Oracle XML Database” Marco Gralike
XML Programming in PL/SQL
Disclaimer The following are  “Rules of Numb” Every environment has its own  unique criteria and needs
 Pay attention to: “Maintainability” “Extendibility” “Choice” “Design” “Testing” “Performance”
“XML is not a ‘fast’ thing, there is a ton of parsing involved. Sorry, I never saw the point in huge XML files – they are many times larger than they should be and the amount of work involved in parsing them is incredible”. Tom Kyte - Januari 9, 2009, AskTom
If you’re a performance nerd,  	this is actually cool
 Lots of ground to cover regarding “XML”
 Solving the customer problem
 Back to basics
 New solutions via XML Deeper understanding of 	the data handling issues
 So why the “
.” XML
?
XML Programming in PL/SQL
Oracle XML Offering Oracle Apps Oracle  Grid Control Oracle Fusion Middleware      Oracle Database J2EE Integration Wireless RAC WebService WebCache BI & Reports DataPump OracleXML DB Portal OID LDAP C/C++ XML Utilities (oraxml10.lib) XSQL TransX Java XML Utilities (xml.jar) (XSU)    JSR170 Class Generator XMLDiff XMLDiff  JAXB      XML Pipeline        Oracle JDeveloper Java XML Processing (xmlparserv2.jar) C XML Processing (oraxml10.lib) XSLT VM XSD SAX DOM DOM SAX JAXP XPath XQuery XSLT XSD Pull XPath Oracle XML Broadband Network— Binary XML  Multi-Platform, Multi-OS Runtime in Java C and C++ NLS (oranls.lib) JDK 1.5 CORE (oracore10.lib) NLS (orai18n*.jar) JDBC (classes12.jar)
History 11g XDB 10gR2 10g Performance, Strictness to Standards 9iR2 XDK 9i 8i XMLType, XSQL XQuery Robustness
XDK or XMLDB ? Oracle XML Developer's Kit (XDK) Is a versatile set of components that enables you to build and deploy C, C++, and Java software programs that process XML Inside and Outside the database Oracle XMLDB  Oracle XML DB is the name for a set of Oracle Database technologies related to high-performance XML storage and retrieval Is officially supported since version 9.2.0.3.0
XML DB - BasedonStandards World Wide Web Consortium(W3) XML, XML Schema, XSLT, XPath, XQuery,  (11gR1) XLink, XInclude International Standard Organisation(ISO) SQL/XML Internet Engineering Task Force (IETF) FTP, HTTP(s), WebDAV Java Community Process Content Repository API for Java, JSR-170 standard
Why Oracle XML Database? It’s XML
 Standard Parsers File Storage or
 XML Database Native XML Enabled Oracle XMLDB ,[object Object]
More than one Option
Complies to Standards
Still License Free
Core part of (OXJR)DBMS
The (relational) foundation is there and can also be used dealing with XML,[object Object]
Milestones – Oracle 9.2/10.1 Oracle Version 9.2.0.3.0 XML DB Build-In instead of a XDK / XMLType CLOB and Object Relational XMLType Storage Oracle 10gR1 Performance, W3C (etc) strict behavior (namespaces!) XML Schema Evolution (copyEvolve)
Milestones – Oracle 10.2 Oracle 10gR2 XQuery and XMLTABLE (XPath V2) Query re-write support for eg. xmltype.extract insertChildXML, appendChildXML, insertXMLbefore, deleteXML XMLType support for Advanced Queueing Oracle 10.2.0.3.0 XQuery (also in XMLTABLE) in Database Kernel (build-in via C instead of Java wrappers)
Milestones – Oracle 11.1 Oracle 11gR1 XMLType Binary XML Storage Support Unstructured XMLIndex Support DeprecatedCTXXPATH index Repository Events, NDWS Xlink & Xinclude and standard W3C XQuery 1.0 Recommendation In-Place XML Schema Evolution 64K limit on text nodes and attribute values has been lifted
Milestones – Oracle 11.2 Oracle 11.1.0.7.0 Oracle Reference or Equi-Partitioning Support Oracle 11.2.0.1.0 Structured XML Index Ability to support huge XML Schema’s Depricated propriety SQL/XML extract, extractvalue, existsnode, 
 Oracle 11.2.0.2.0 Binary XML default for XMLType (instead of CLOB) Depricated?:  ora:view
Oracle XML DB SQL*Net  Protocol Server Thin, Thick Clients XMLDB Functionality
XML Data Handling XML data exchange SQL, C, C++, Java, PL/SQL, .Net, etc Via Protocol Listener supported methods XML data storage CLOB, Object Relational, Binary XML (11gRx) XML data validation XMLSchema, programmatically XML data creation XML Operators, Packages
XML DB Mayor Features Storagebasedon the XMLType datatype  XMLType Column, XMLTypeTable Retrievalof data via XML/SQL, XPath, XQuery Securitybasedon ACL, Oracle Roles The Protocol Server HTTP(s), FTP, WebDAV, Native Database WebServices (NDWS) The XMLDB Repository XMLSchema Support and Evolution Versioning, CMS Features
XML Programming in PL/SQL
Document contra Data Driven
What is big XML ? Less than 1 Kb Bigger than 1 Mb Complexity Symptoms: ,[object Object],	contains too many nodes  ,[object Object]
1000 column issue,[object Object]
In Memory: Common XML Parsers Often handle XML tree traversals only via  ONEmethod It is not structured, semi-structured or unstructured XML content aware It is not very “smart” / “content aware” regarding XMLhandling based on its XML tree’s and/or XML data content
The “Dimensions” in 1 XML doc. 1 3 4 5 2 X Y 6 Z nx rows  Elements with maxoccurs=“unbounded”
XMLType XML Container (in memory or via storage) In Memory (document) CLOB (document) Object Relational (data) Binary XML (data)
Complexities of a database “Relations” “Redundancy” “Nullology” Design, etc
 It can contain a database 10 Mb or bigger nowadays More often than less
 Enormous complex XSD’s  XMLType – Not just a “Container”
Checked on XML Well-Formedness One root element Begin & End tags If XML Schema reference XOB methods will be used if an XML Schema is available (faster, smaller/less data) DOM methods will be used if registered  	XML Schema information is not available  XMLType – Not just a “Datatype”
XML Operators & Functions DELETEXML EXTRACTVALUE EXISTNODE EXTRACT INSERTCHILDXML INSERTXMLBEFORE SYS_XMLAGG SYS_XMLGEN UPDATEXML APPENDCHILDXML XMLAGG XMLCAST XMLCDATA XMLCOLATTVAL XMLCOMMENT XMLCONCAT XMLDIFF XMLELEMENT XMLEXISTS XMLFOREST XMLPARSE XMLPATCH XMLPI XMLQUERY XMLROOT XMLSEQUENCE XMLSERIALIZE XMLTABLE XMLTRANSFORM etc.,etc.,etc.

XML Operators & Functions
and Packages HTTPURITYPE XDBURITYPE DBURITYPE DBMS_XMLSCHEMA DBMS_XMLDOM DBMS_XMLQUERY DBMS_XMLPARSER DBMS_XMLGEN DBMS_XMLSAVE DBMS_XMLSTORE DBMS_XSLPROCESSOR DBMS_XMLTRANSLATIONS DBMS_METADATA
 XMLVIEW XMLTYPE
 Handles almost any datatype CLOB, VARCHAR2, ADT,SYS_REFCURSOR, ANYDATA, BLOB, BFILE xmltype.createXML() xmltype.toobject() xmltype.transform()
Wow, so what to choose
? Performance C based or Java based solutions Deprecated in the near Future Follow the general XML standard Engine enhancements XPath V2 (XMLTable, XMLQuery) Binary XML support Let Oracle do the Work “Am ”||” i “||” stupid?”,CLOB instead of XMLType
Java Based or C Kernel embedded? XQuery (10.2.0.1) 8i related: XMLDOM, XMLPARSER, XMLProcessor DBMS_XMLQUERY DBMS_XMLGEN DBMS_XMLSAVE Pre 11.2.0.0.0 (JVM) ? XQuery (10.2.0.3.0 ) DBMS_XMLDOM DBMS_XMLPROCESSOR XQuery, DBMS_XMLGEN SQL/XML  DBMS_XMLSTORE Post 11.2.0.1.0 (no JVM) ?
Deprecated in 11.2.0.1.0 EXTRACT EXTRACTVALUE EXISTNODE XMLSEQUENCE ora:instanceof ora:instanceof-only getStringVal(), getClobVal(), getBlobVal() getNamespace() getRootElement() Function-based Indexes (XML) XMLQuery XMLTable, XMLCast, XMLQuery XMLExists XMLTable XQuery instance operator XML Schema attribute xsi:type XMLSerialize XQuery function fn:namespace-uri XQuery function fn:local-name Structured XMLIndex
XML Programming in PL/SQL
Select (XML) data (everywhere) XDB Repository content  xdburitype (11.2.0.2: ora:defaultTable) Database server directory content (bfilename) World Wide Web (httpuritype) ,[object Object],Relational content  XMLTable, XQuery dburitype, view  ora:view (11.2.0.2: fn:doc /fn:collection)
XDB Repository declare   res BOOLEAN; begin   res := dbms_xdb.createResource                           ('/public/q1.xqy',                           <My Xquery>);   commit; end; /  SELECT xmlquery(xdburitype('/public/q1.xqy').getClob()         passing OBJECT_VALUE         returning content)  FROM   MY_XML_TABLE /
SQL> SELECT xdata 2  FROM (XMLTABLE( 3         '*'  4         PASSING    5           (XMLTYPE(bfilename('XMLSTORE','data.xml') 6                      ,NLS_CHARSET_ID('AL32UTF8'))) 7         COLUMNS xdataXMLTYPE path '/*')); XDATA ------------------------------------ <root><content>Text</content></root> 1 row selected. XML data from your Local Disk
SQL> SELECT *   2  FROM XMLTABLE 3    (XMLNAMESPACES('http://purl.org/dc/elements/1.1/'  4     as “MGR")   5     ,'//item' 6PASSING   HTTPURITYPE('http://my.blog.com/blog/?feed=rss2').getXML() 7     COLUMNS title varchar2(50)  8                   path'/item/title/text()', 9             link  varchar2(50)  10                   path '/item/link/text()', 11             publication_datevarchar2(50)  12                   path '/item/pubDate/text()', 13             creator varchar2(50)  14                   path '/item/MGR:creator/text()', 15             description varchar2(250)  16                   path '/item/description/text()'); RSS Example (1)
TITLE     LINK     PUBLICATION_DATE      CREATOR ------------------------------------------------------------ DESCRIPTION ------------------------------------------------------------ Quering RSS Feeds The XMLDB Way http://feeds.feedburner.com/~r/Bloggralikecom/~3/3 Wed, 25 Jun 2008 16:47:19 +0000 Marco Gralike Actually this IS old stuff (2006), but it got lost IN a
  RSS Example (2)
SQL> SELECT table_name 2  ,   to_number( 3      extractvalue(xmltype(dbms_xmlgen.getxml 4                             ('select count(*) C  5                               from '||table_name)) 6                           ,'/ROWSET/ROW/C')) count 7  FROM user_tables; TABLE_NAME                      COUNT ------------------------------ ------ DEPT                                4 EMP                                14 BONUS                               0 SALGRADE                            5 Using XML operators with SQL Source Laurent Schneider:How do i store the counts of all tables 

XQuery on PL/SQL variable DECLARE v_x XMLType; NumAcc NUMBER; BEGIN v_x := XMLType(
); /* initialize xmltype variable */ 	SELECT /*+ NO_XML_QUERY_REWRITE */ XMLCAST(XMLQUERY('declare default element namespace 		"http://custacc";for $cust in $cadoc/Customer         return fn:count($cust/Addresses/Address)' PASSINGv_x AS "cadoc" RETURNING CONTENT) AS NUMBER) 	INTO NumAcc 	FROM DUAL; END; Hint allows efficient DOM based evaluation XMLExists() can be used similarly Source OOW 2010 “Managing XML Content with XML DB: Getting the Best Bang for the Buck”
Select (XML) data VIEW DBMS_XMLDOM DBMS_XMLPARSER XQUERY
XML Programming in PL/SQL
When to use XMLType Query against XML data Take advantage of structure when you have an XML schema Provide efficient XPath access Shield applications from storage models  Prepare for future optimizations  Provide structured storage with  DOM fidelity
Create XML Relational Content XMLType XMLView XQuery DBMS_XML{Packages} Object Orientated Content XML Content Document Content BFilename, BLOB, CLOB, EXIF

Canonical XMLType Result Set XMLType - Very powerful (
and simple) SQL> select xmltype(cursor(select * fromscott.dept 2whererownum=1))    3  as     "Result"   4fromdual; Result --------------------------------------------------------- <?xmlversion="1.0"?> <ROWSET>  <ROW>   <DEPTNO>10</DEPTNO>   <DNAME>ACCOUNTING</DNAME>   <LOC>NEW YORK</LOC>  </ROW> </ROWSET>
SQL/XML XMLELEMENT, XMLATTRIBUTES, XMLFOREST, XMLSEQUENCE, XMLCONCAT, XMLAGG XMLTABLE, XMLQUERY XMLEXIST, XMLCAST SYS_XMLGEN, SYS_XMLAGG DBMS_XML{PACKAGES}
Master – Detail (1) SELECTdepartment_id as "ID",  XMLElement("Department",  XMLAttributes(d.department_name "name"),    					(SELECTXMLAgg( XMLElement("emp",  XMLAttributes(e.last_name name),    								(SELECTXMLAgg( XMLElement("jobs",  XMLAttributes(j.job_id "job")))  FROMjob_history j  WHERE j.employee_id=e.employee_id)))  FROM   employees e  WHEREe.department_id=d.department_id)) AS “MD"  FROM 		departments d  WHERE 	department_id < 40;
Master – Detail (2) ID 	MD  --------- 	--------------------------------------- 90 				<Department name="Executive">  	<emp NAME="King"/>  	<emp NAME="Kochhar">  	<jobs job="AC_ACCOUNT"/>  	<jobs job="AC_MGR"/>  	</emp>  	<emp NAME="De Haan">  	<jobs job="IT_PROG"/>  	</emp>  	</Department> 
rows selected.
Native XML Generation Generate XML documents by using : SYS_XMLGEN, to accept a single argument and generate an XML document for each row from a SQL statement SYS_XMLAGG, to process groups of rows, aggregating several XML fragments into a single XML document In PL/SQL, use the DBMS_XMLGEN package to execute any SQL query and map the results into an XML document as a CLOB or XMLType.
SYS_XMLGEN() Function Converts its argument into an XML document Accepts two arguments: A scalar value, object type, or XMLType instance An optional XMLFormat() object Returns an XMLType instance Creates and queries XML instances within SQL SELECT 	SYS_XMLGEN(	XMLForest (last_name, salary), XMLFormat('EMPLOYEE')) FROM 		employees  WHERE 	department_id = 30;
SYS_XMLAGG() Function The SYS_XMLAGG() function: Groups all the input documents and produces a single XML document Is used to aggregate (concatenate) fragments  SELECT 	SYS_XMLAGG( SYS_XMLGEN(last_name), XMLFormat('Employees')) result  FROM employees  WHERE 	department_id < 30  GROUP BY  	department_id;
DBMS_XMLGEN Creates an XML document from SQL query, XMLType Gets the document as a CLOB Provides a fetch interface  Is useful for pagination in Web applications
DBMS_XMLGEN (1) CREATE TABLE temp_clob_tab(result CLOB);  DECLARE  		qryCtx DBMS_XMLGEN.ctxHandle;  		result CLOB;  BEGIN  qryCtx :=  DBMS_XMLGEN.newContext('SELECT * FROM hr.employees');  		-- Set the row header to be EMPLOYEE  DBMS_XMLGEN.setRowTag(qryCtx, 'EMPLOYEE');  		-- Get the result  		result := DBMS_XMLGEN.getXML(qryCtx);  		INSERT INTO temp_clob_tab VALUES(result);  		--Close context  DBMS_XMLGEN.closeContext(qryCtx);  END;  /
DBMS_XMLGEN (2) RESULT  ------------------------------------------------ <?xml version="1.0"?>  <ROWSET>  		<EMPLOYEE>  			<EMPLOYEE_ID>100</EMPLOYEE_ID> 	 			<FIRST_NAME>Steven</FIRST_NAME>  			<LAST_NAME>King</LAST_NAME>  			<EMAIL>SKING</EMAIL> 				 			<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>  			<HIRE_DATE>17-JUN-87</HIRE_DATE>  			<JOB_ID>AD_PRES</JOB_ID>  			<SALARY>24000</SALARY>  			<DEPARTMENT_ID>90</DEPARTMENT_ID>  		</EMPLOYEE> 
 </ROWSET>
Create XML data DBMS_XMLDOM SYS	_XMLGEN XMLVIEW
XML Programming in PL/SQL
National LanguageSettings CHARACTER SET: AL32UTF8 NATIONAL CHARACTER SET: AL16UTF16 NLS_LENGTH_SEMANTICS ='BYTE'; Before $ORACLE_HOMEDBMSDMINatqm.sql Avoid “Strange” NLS related errors: Registering an XML Schema via WebDAV, Drag & Drop Registering an XML Schema via BFILENAME
Database character set is AL32UTF  Client character set is WIN1252.   SQL> drop table test; SQL> create table test of xmltype; SQL> insert into test values  (xmltype( '<?xml version="1.0" encoding="UTF-8"?><FOO/>')); SQL> select object_value from test; OBJECT_VALUE --------------------------------------------------- <?xml version="1.0" encoding="WINDOWS-1252"?><FOO/> NLS FAQ (1)
SQL> select x.object_value.getClobVal() from test x; X.OBJECT_VALUE.GETCLOBVAL() -------------------------------------------- <?xml version="1.0" encoding="UTF-8"?><FOO/> SQL> exit C:EMP>set NLS_LANG=AMERICAN_AMERICA.AL32UTF8 C:EMP>sqlplusscott/tiger SQL> select *  from test; SYS_NC_ROWINFO$ -------------------------------------------- <?xml version="1.0" encoding="UTF-8"?><FOO/> NLS FAQ (2)
ORA-24247 ORA-24247  Network access denied by access control list, ACL Packages involved (11gR1) UTL_TCP, UTL_SMTP,  UTL_MAIL, UTL_HTTP, UTL_INADDR Solution: DBMS_NETWORK_ACL_ADMIN Check, Add, Remove Privileges
Troubleshooting XMLDB Use What You Know: SET AUTOTRACE ON, DBMS_XPLAN.DISPLAY, TKPROF, SQL_TRACE, EVENTS like 10046 etc. Schema Registration: ALTER session SET events = '31098 trace name context forever' Protocol Server: ALTER system SET event = '31098 trace name context forever, level 2' scope=spfile Trace files  UDUMP Directory
Small tip regarding “alias” usage Using an alias called: “X”, “Y” (and not Z
) SQL> select * from v$versionwhererownum=1; BANNER --------------------------------------------------------- Oracle Database 10g EnterpriseEdition Release 10.2.0.4.0 SQL> describeX FUNCTION X RETURNS NUMBER  Argument Name                  Type                    In/Out Default?  ------------------------------ ----------------------- ------ --------  P                              ST_POINT                IN SQL> describeY FUNCTION Y RETURNS NUMBER  Argument Name                  Type                    In/Out Default?  ------------------------------ ----------------------- ------ --------  P                              ST_POINT                IN

Weitere Àhnliche Inhalte

Was ist angesagt?

Radical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the HoodRadical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the Hood
Databricks
 

Was ist angesagt? (20)

Radical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the HoodRadical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the Hood
 
APEX Themes and Templates
APEX Themes and TemplatesAPEX Themes and Templates
APEX Themes and Templates
 
Part3 Explain the Explain Plan
Part3 Explain the Explain PlanPart3 Explain the Explain Plan
Part3 Explain the Explain Plan
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
 
Oracle ERP Cloud
Oracle ERP CloudOracle ERP Cloud
Oracle ERP Cloud
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
E34 : [JPOUG Presents] Oracle Database ăźéš ă•ă‚ŒăŠă„ă‚‹æ§˜ă€…ăȘèŹŽă‚’è§Łăă‚»ăƒƒă‚·ăƒ§ăƒłă€ŒăȘăƒŒă‚“ă§ă ïŒŸă€ć†ăł @ db tec...
E34 : [JPOUG Presents] Oracle Database ăźéš ă•ă‚ŒăŠă„ă‚‹æ§˜ă€…ăȘèŹŽă‚’è§Łăă‚»ăƒƒă‚·ăƒ§ăƒłă€ŒăȘăƒŒă‚“ă§ă ïŒŸă€ć†ăł @ db tec...E34 : [JPOUG Presents] Oracle Database ăźéš ă•ă‚ŒăŠă„ă‚‹æ§˜ă€…ăȘèŹŽă‚’è§Łăă‚»ăƒƒă‚·ăƒ§ăƒłă€ŒăȘăƒŒă‚“ă§ă ïŒŸă€ć†ăł @ db tec...
E34 : [JPOUG Presents] Oracle Database ăźéš ă•ă‚ŒăŠă„ă‚‹æ§˜ă€…ăȘèŹŽă‚’è§Łăă‚»ăƒƒă‚·ăƒ§ăƒłă€ŒăȘăƒŒă‚“ă§ă ïŒŸă€ć†ăł @ db tec...
 
DDD 2016 DB 12c クスăƒȘăƒŒăƒ»ă‚Șăƒ—ăƒ†ă‚Łăƒžă‚€ă‚¶æ–°æ©ŸèƒœæŽ»ç”šăšç”±èšˆæƒ…ć ±é‹ç”šăźæˆŠç•„
DDD 2016 DB 12c クスăƒȘăƒŒăƒ»ă‚Șăƒ—ăƒ†ă‚Łăƒžă‚€ă‚¶æ–°æ©ŸèƒœæŽ»ç”šăšç”±èšˆæƒ…ć ±é‹ç”šăźæˆŠç•„DDD 2016 DB 12c クスăƒȘăƒŒăƒ»ă‚Șăƒ—ăƒ†ă‚Łăƒžă‚€ă‚¶æ–°æ©ŸèƒœæŽ»ç”šăšç”±èšˆæƒ…ć ±é‹ç”šăźæˆŠç•„
DDD 2016 DB 12c クスăƒȘăƒŒăƒ»ă‚Șăƒ—ăƒ†ă‚Łăƒžă‚€ă‚¶æ–°æ©ŸèƒœæŽ»ç”šăšç”±èšˆæƒ…ć ±é‹ç”šăźæˆŠç•„
 
Web analytics at scale with Druid at naver.com
Web analytics at scale with Druid at naver.comWeb analytics at scale with Druid at naver.com
Web analytics at scale with Druid at naver.com
 
Polymorphic Table Functions in SQL
Polymorphic Table Functions in SQLPolymorphic Table Functions in SQL
Polymorphic Table Functions in SQL
 
Introduction to Oracle ASCP and Demantra
Introduction to Oracle ASCP and DemantraIntroduction to Oracle ASCP and Demantra
Introduction to Oracle ASCP and Demantra
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them All
 
MySQLăźă‚œăƒŒă‚čăƒ»ă‚żăƒŒă‚Čăƒƒăƒˆă‚šăƒłăƒ‰ăƒă‚€ăƒłăƒˆăšă—ăŠăźćˆ©ç”š
MySQLăźă‚œăƒŒă‚čăƒ»ă‚żăƒŒă‚Čăƒƒăƒˆă‚šăƒłăƒ‰ăƒă‚€ăƒłăƒˆăšă—ăŠăźćˆ©ç”šMySQLăźă‚œăƒŒă‚čăƒ»ă‚żăƒŒă‚Čăƒƒăƒˆă‚šăƒłăƒ‰ăƒă‚€ăƒłăƒˆăšă—ăŠăźćˆ©ç”š
MySQLăźă‚œăƒŒă‚čăƒ»ă‚żăƒŒă‚Čăƒƒăƒˆă‚šăƒłăƒ‰ăƒă‚€ăƒłăƒˆăšă—ăŠăźćˆ©ç”š
 
ABAP 7.x New Features and Commands
ABAP 7.x New Features and CommandsABAP 7.x New Features and Commands
ABAP 7.x New Features and Commands
 
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle TextFind Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
 
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
 
Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?
 
AWSKRUG DS - 데읎터 엔지니얎가 ì‹€ëŹŽì—ì„œ ë§žë‹„ëœšëŠŹëŠ” ëŹžì œë“€
AWSKRUG DS - 데읎터 엔지니얎가 ì‹€ëŹŽì—ì„œ ë§žë‹„ëœšëŠŹëŠ” ëŹžì œë“€AWSKRUG DS - 데읎터 엔지니얎가 ì‹€ëŹŽì—ì„œ ë§žë‹„ëœšëŠŹëŠ” ëŹžì œë“€
AWSKRUG DS - 데읎터 엔지니얎가 ì‹€ëŹŽì—ì„œ ë§žë‹„ëœšëŠŹëŠ” ëŹžì œë“€
 
Oracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with descriptionOracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with description
 

Ähnlich wie OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1

Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Marco Gralike
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
Marco Gralike
 
IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons Learned
Ted Leung
 
Data interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTDData interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTD
AnushaMahmood
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologies
Bat Programmer
 
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
InSync2011
 

Ähnlich wie OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1 (20)

Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 
Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will Perform
 
Expertezed 2012 Webcast - XML DB Use Cases
Expertezed 2012 Webcast - XML DB Use CasesExpertezed 2012 Webcast - XML DB Use Cases
Expertezed 2012 Webcast - XML DB Use Cases
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
 
JSON in der Oracle Datenbank
JSON in der Oracle DatenbankJSON in der Oracle Datenbank
JSON in der Oracle Datenbank
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
 
ODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XMLODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XML
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
 
IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons Learned
 
Xml
XmlXml
Xml
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Data interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTDData interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTD
 
Ch23
Ch23Ch23
Ch23
 
Ch23 xml processing_with_java
Ch23 xml processing_with_javaCh23 xml processing_with_java
Ch23 xml processing_with_java
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologies
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptx
 
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
Developer & Fusion Middleware 1 | Mark Drake | An introduction to Oracle XML ...
 

Mehr von Marco Gralike

BGOUG 2012 - Design concepts for xml applications that will perform
BGOUG 2012 - Design concepts for xml applications that will performBGOUG 2012 - Design concepts for xml applications that will perform
BGOUG 2012 - Design concepts for xml applications that will perform
Marco Gralike
 
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File ServerUKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
Marco Gralike
 

Mehr von Marco Gralike (20)

UKOUG2018 - I Know what you did Last Summer [in my Database].pptx
UKOUG2018 - I Know what you did Last Summer [in my Database].pptxUKOUG2018 - I Know what you did Last Summer [in my Database].pptx
UKOUG2018 - I Know what you did Last Summer [in my Database].pptx
 
eProseed Oracle Open World 2016 debrief - Oracle Management Cloud
eProseed Oracle Open World 2016 debrief - Oracle Management CloudeProseed Oracle Open World 2016 debrief - Oracle Management Cloud
eProseed Oracle Open World 2016 debrief - Oracle Management Cloud
 
eProseed Oracle Open World 2016 debrief - Oracle 12.2.0.1 Database
eProseed Oracle Open World 2016 debrief - Oracle 12.2.0.1 DatabaseeProseed Oracle Open World 2016 debrief - Oracle 12.2.0.1 Database
eProseed Oracle Open World 2016 debrief - Oracle 12.2.0.1 Database
 
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory DatabaseOracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory Database
 
UKOUG Tech15 - Going Full Circle - Building a native JSON Database API
UKOUG Tech15 - Going Full Circle - Building a native JSON Database APIUKOUG Tech15 - Going Full Circle - Building a native JSON Database API
UKOUG Tech15 - Going Full Circle - Building a native JSON Database API
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
 
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseUKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
 
UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex DatatypesUKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
 
Ordina Oracle Open World
Ordina Oracle Open WorldOrdina Oracle Open World
Ordina Oracle Open World
 
Starting with JSON Path Expressions in Oracle 12.1.0.2
Starting with JSON Path Expressions in Oracle 12.1.0.2Starting with JSON Path Expressions in Oracle 12.1.0.2
Starting with JSON Path Expressions in Oracle 12.1.0.2
 
An introduction into Oracle VM V3.x
An introduction into Oracle VM V3.xAn introduction into Oracle VM V3.x
An introduction into Oracle VM V3.x
 
An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3
An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3
An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3
 
XML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured dataXML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured data
 
An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)
 
Flexibiliteit & Snel Schakelen
Flexibiliteit & Snel SchakelenFlexibiliteit & Snel Schakelen
Flexibiliteit & Snel Schakelen
 
Hotsos 2013 - Creating Structure in Unstructured Data
Hotsos 2013 - Creating Structure in Unstructured DataHotsos 2013 - Creating Structure in Unstructured Data
Hotsos 2013 - Creating Structure in Unstructured Data
 
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file serverBGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
 
BGOUG 2012 - XML Index Strategies
BGOUG 2012 - XML Index StrategiesBGOUG 2012 - XML Index Strategies
BGOUG 2012 - XML Index Strategies
 
BGOUG 2012 - Design concepts for xml applications that will perform
BGOUG 2012 - Design concepts for xml applications that will performBGOUG 2012 - Design concepts for xml applications that will perform
BGOUG 2012 - Design concepts for xml applications that will perform
 
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File ServerUKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
 

KĂŒrzlich hochgeladen

KĂŒrzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1

  • 1. XML Programming in PL/SQL (Part 1)“An Introduction to the Oracle XML Database” Marco Gralike
  • 3.
  • 4.
  • 5. Disclaimer The following are “Rules of Numb” Every environment has its own unique criteria and needs
 Pay attention to: “Maintainability” “Extendibility” “Choice” “Design” “Testing” “Performance”
  • 6. “XML is not a ‘fast’ thing, there is a ton of parsing involved. Sorry, I never saw the point in huge XML files – they are many times larger than they should be and the amount of work involved in parsing them is incredible”. Tom Kyte - Januari 9, 2009, AskTom
  • 7. If you’re a performance nerd, this is actually cool
 Lots of ground to cover regarding “XML”
 Solving the customer problem
 Back to basics
 New solutions via XML Deeper understanding of the data handling issues
 So why the “
.” XML
?
  • 9. Oracle XML Offering Oracle Apps Oracle Grid Control Oracle Fusion Middleware Oracle Database J2EE Integration Wireless RAC WebService WebCache BI & Reports DataPump OracleXML DB Portal OID LDAP C/C++ XML Utilities (oraxml10.lib) XSQL TransX Java XML Utilities (xml.jar) (XSU) JSR170 Class Generator XMLDiff XMLDiff JAXB XML Pipeline Oracle JDeveloper Java XML Processing (xmlparserv2.jar) C XML Processing (oraxml10.lib) XSLT VM XSD SAX DOM DOM SAX JAXP XPath XQuery XSLT XSD Pull XPath Oracle XML Broadband Network— Binary XML Multi-Platform, Multi-OS Runtime in Java C and C++ NLS (oranls.lib) JDK 1.5 CORE (oracore10.lib) NLS (orai18n*.jar) JDBC (classes12.jar)
  • 10. History 11g XDB 10gR2 10g Performance, Strictness to Standards 9iR2 XDK 9i 8i XMLType, XSQL XQuery Robustness
  • 11. XDK or XMLDB ? Oracle XML Developer's Kit (XDK) Is a versatile set of components that enables you to build and deploy C, C++, and Java software programs that process XML Inside and Outside the database Oracle XMLDB Oracle XML DB is the name for a set of Oracle Database technologies related to high-performance XML storage and retrieval Is officially supported since version 9.2.0.3.0
  • 12. XML DB - BasedonStandards World Wide Web Consortium(W3) XML, XML Schema, XSLT, XPath, XQuery, (11gR1) XLink, XInclude International Standard Organisation(ISO) SQL/XML Internet Engineering Task Force (IETF) FTP, HTTP(s), WebDAV Java Community Process Content Repository API for Java, JSR-170 standard
  • 13.
  • 14. More than one Option
  • 17. Core part of (OXJR)DBMS
  • 18.
  • 19. Milestones – Oracle 9.2/10.1 Oracle Version 9.2.0.3.0 XML DB Build-In instead of a XDK / XMLType CLOB and Object Relational XMLType Storage Oracle 10gR1 Performance, W3C (etc) strict behavior (namespaces!) XML Schema Evolution (copyEvolve)
  • 20. Milestones – Oracle 10.2 Oracle 10gR2 XQuery and XMLTABLE (XPath V2) Query re-write support for eg. xmltype.extract insertChildXML, appendChildXML, insertXMLbefore, deleteXML XMLType support for Advanced Queueing Oracle 10.2.0.3.0 XQuery (also in XMLTABLE) in Database Kernel (build-in via C instead of Java wrappers)
  • 21. Milestones – Oracle 11.1 Oracle 11gR1 XMLType Binary XML Storage Support Unstructured XMLIndex Support DeprecatedCTXXPATH index Repository Events, NDWS Xlink & Xinclude and standard W3C XQuery 1.0 Recommendation In-Place XML Schema Evolution 64K limit on text nodes and attribute values has been lifted
  • 22. Milestones – Oracle 11.2 Oracle 11.1.0.7.0 Oracle Reference or Equi-Partitioning Support Oracle 11.2.0.1.0 Structured XML Index Ability to support huge XML Schema’s Depricated propriety SQL/XML extract, extractvalue, existsnode, 
 Oracle 11.2.0.2.0 Binary XML default for XMLType (instead of CLOB) Depricated?: ora:view
  • 23. Oracle XML DB SQL*Net Protocol Server Thin, Thick Clients XMLDB Functionality
  • 24. XML Data Handling XML data exchange SQL, C, C++, Java, PL/SQL, .Net, etc Via Protocol Listener supported methods XML data storage CLOB, Object Relational, Binary XML (11gRx) XML data validation XMLSchema, programmatically XML data creation XML Operators, Packages
  • 25. XML DB Mayor Features Storagebasedon the XMLType datatype XMLType Column, XMLTypeTable Retrievalof data via XML/SQL, XPath, XQuery Securitybasedon ACL, Oracle Roles The Protocol Server HTTP(s), FTP, WebDAV, Native Database WebServices (NDWS) The XMLDB Repository XMLSchema Support and Evolution Versioning, CMS Features
  • 28.
  • 29.
  • 30. In Memory: Common XML Parsers Often handle XML tree traversals only via ONEmethod It is not structured, semi-structured or unstructured XML content aware It is not very “smart” / “content aware” regarding XMLhandling based on its XML tree’s and/or XML data content
  • 31. The “Dimensions” in 1 XML doc. 1 3 4 5 2 X Y 6 Z nx rows Elements with maxoccurs=“unbounded”
  • 32. XMLType XML Container (in memory or via storage) In Memory (document) CLOB (document) Object Relational (data) Binary XML (data)
  • 33. Complexities of a database “Relations” “Redundancy” “Nullology” Design, etc
 It can contain a database 10 Mb or bigger nowadays More often than less
 Enormous complex XSD’s XMLType – Not just a “Container”
  • 34. Checked on XML Well-Formedness One root element Begin & End tags If XML Schema reference XOB methods will be used if an XML Schema is available (faster, smaller/less data) DOM methods will be used if registered XML Schema information is not available XMLType – Not just a “Datatype”
  • 35. XML Operators & Functions DELETEXML EXTRACTVALUE EXISTNODE EXTRACT INSERTCHILDXML INSERTXMLBEFORE SYS_XMLAGG SYS_XMLGEN UPDATEXML APPENDCHILDXML XMLAGG XMLCAST XMLCDATA XMLCOLATTVAL XMLCOMMENT XMLCONCAT XMLDIFF XMLELEMENT XMLEXISTS XMLFOREST XMLPARSE XMLPATCH XMLPI XMLQUERY XMLROOT XMLSEQUENCE XMLSERIALIZE XMLTABLE XMLTRANSFORM etc.,etc.,etc.

  • 36. XML Operators & Functions
and Packages HTTPURITYPE XDBURITYPE DBURITYPE DBMS_XMLSCHEMA DBMS_XMLDOM DBMS_XMLQUERY DBMS_XMLPARSER DBMS_XMLGEN DBMS_XMLSAVE DBMS_XMLSTORE DBMS_XSLPROCESSOR DBMS_XMLTRANSLATIONS DBMS_METADATA
 XMLVIEW XMLTYPE
 Handles almost any datatype CLOB, VARCHAR2, ADT,SYS_REFCURSOR, ANYDATA, BLOB, BFILE xmltype.createXML() xmltype.toobject() xmltype.transform()
  • 37. Wow, so what to choose
? Performance C based or Java based solutions Deprecated in the near Future Follow the general XML standard Engine enhancements XPath V2 (XMLTable, XMLQuery) Binary XML support Let Oracle do the Work “Am ”||” i “||” stupid?”,CLOB instead of XMLType
  • 38. Java Based or C Kernel embedded? XQuery (10.2.0.1) 8i related: XMLDOM, XMLPARSER, XMLProcessor DBMS_XMLQUERY DBMS_XMLGEN DBMS_XMLSAVE Pre 11.2.0.0.0 (JVM) ? XQuery (10.2.0.3.0 ) DBMS_XMLDOM DBMS_XMLPROCESSOR XQuery, DBMS_XMLGEN SQL/XML DBMS_XMLSTORE Post 11.2.0.1.0 (no JVM) ?
  • 39. Deprecated in 11.2.0.1.0 EXTRACT EXTRACTVALUE EXISTNODE XMLSEQUENCE ora:instanceof ora:instanceof-only getStringVal(), getClobVal(), getBlobVal() getNamespace() getRootElement() Function-based Indexes (XML) XMLQuery XMLTable, XMLCast, XMLQuery XMLExists XMLTable XQuery instance operator XML Schema attribute xsi:type XMLSerialize XQuery function fn:namespace-uri XQuery function fn:local-name Structured XMLIndex
  • 41.
  • 42. XDB Repository declare res BOOLEAN; begin res := dbms_xdb.createResource ('/public/q1.xqy', <My Xquery>); commit; end; / SELECT xmlquery(xdburitype('/public/q1.xqy').getClob() passing OBJECT_VALUE returning content) FROM MY_XML_TABLE /
  • 43. SQL> SELECT xdata 2 FROM (XMLTABLE( 3 '*' 4 PASSING 5 (XMLTYPE(bfilename('XMLSTORE','data.xml') 6 ,NLS_CHARSET_ID('AL32UTF8'))) 7 COLUMNS xdataXMLTYPE path '/*')); XDATA ------------------------------------ <root><content>Text</content></root> 1 row selected. XML data from your Local Disk
  • 44. SQL> SELECT * 2 FROM XMLTABLE 3 (XMLNAMESPACES('http://purl.org/dc/elements/1.1/' 4 as “MGR") 5 ,'//item' 6PASSING HTTPURITYPE('http://my.blog.com/blog/?feed=rss2').getXML() 7 COLUMNS title varchar2(50) 8 path'/item/title/text()', 9 link varchar2(50) 10 path '/item/link/text()', 11 publication_datevarchar2(50) 12 path '/item/pubDate/text()', 13 creator varchar2(50) 14 path '/item/MGR:creator/text()', 15 description varchar2(250) 16 path '/item/description/text()'); RSS Example (1)
  • 45. TITLE LINK PUBLICATION_DATE CREATOR ------------------------------------------------------------ DESCRIPTION ------------------------------------------------------------ Quering RSS Feeds The XMLDB Way http://feeds.feedburner.com/~r/Bloggralikecom/~3/3 Wed, 25 Jun 2008 16:47:19 +0000 Marco Gralike Actually this IS old stuff (2006), but it got lost IN a
 RSS Example (2)
  • 46. SQL> SELECT table_name 2 , to_number( 3 extractvalue(xmltype(dbms_xmlgen.getxml 4 ('select count(*) C 5 from '||table_name)) 6 ,'/ROWSET/ROW/C')) count 7 FROM user_tables; TABLE_NAME COUNT ------------------------------ ------ DEPT 4 EMP 14 BONUS 0 SALGRADE 5 Using XML operators with SQL Source Laurent Schneider:How do i store the counts of all tables 

  • 47. XQuery on PL/SQL variable DECLARE v_x XMLType; NumAcc NUMBER; BEGIN v_x := XMLType(
); /* initialize xmltype variable */ SELECT /*+ NO_XML_QUERY_REWRITE */ XMLCAST(XMLQUERY('declare default element namespace "http://custacc";for $cust in $cadoc/Customer return fn:count($cust/Addresses/Address)' PASSINGv_x AS "cadoc" RETURNING CONTENT) AS NUMBER) INTO NumAcc FROM DUAL; END; Hint allows efficient DOM based evaluation XMLExists() can be used similarly Source OOW 2010 “Managing XML Content with XML DB: Getting the Best Bang for the Buck”
  • 48. Select (XML) data VIEW DBMS_XMLDOM DBMS_XMLPARSER XQUERY
  • 50. When to use XMLType Query against XML data Take advantage of structure when you have an XML schema Provide efficient XPath access Shield applications from storage models Prepare for future optimizations Provide structured storage with DOM fidelity
  • 51. Create XML Relational Content XMLType XMLView XQuery DBMS_XML{Packages} Object Orientated Content XML Content Document Content BFilename, BLOB, CLOB, EXIF

  • 52. Canonical XMLType Result Set XMLType - Very powerful (
and simple) SQL> select xmltype(cursor(select * fromscott.dept 2whererownum=1)) 3 as "Result" 4fromdual; Result --------------------------------------------------------- <?xmlversion="1.0"?> <ROWSET> <ROW> <DEPTNO>10</DEPTNO> <DNAME>ACCOUNTING</DNAME> <LOC>NEW YORK</LOC> </ROW> </ROWSET>
  • 53. SQL/XML XMLELEMENT, XMLATTRIBUTES, XMLFOREST, XMLSEQUENCE, XMLCONCAT, XMLAGG XMLTABLE, XMLQUERY XMLEXIST, XMLCAST SYS_XMLGEN, SYS_XMLAGG DBMS_XML{PACKAGES}
  • 54. Master – Detail (1) SELECTdepartment_id as "ID", XMLElement("Department", XMLAttributes(d.department_name "name"), (SELECTXMLAgg( XMLElement("emp", XMLAttributes(e.last_name name), (SELECTXMLAgg( XMLElement("jobs", XMLAttributes(j.job_id "job"))) FROMjob_history j WHERE j.employee_id=e.employee_id))) FROM employees e WHEREe.department_id=d.department_id)) AS “MD" FROM departments d WHERE department_id < 40;
  • 55. Master – Detail (2) ID MD --------- --------------------------------------- 90 <Department name="Executive"> <emp NAME="King"/> <emp NAME="Kochhar"> <jobs job="AC_ACCOUNT"/> <jobs job="AC_MGR"/> </emp> <emp NAME="De Haan"> <jobs job="IT_PROG"/> </emp> </Department> 
rows selected.
  • 56. Native XML Generation Generate XML documents by using : SYS_XMLGEN, to accept a single argument and generate an XML document for each row from a SQL statement SYS_XMLAGG, to process groups of rows, aggregating several XML fragments into a single XML document In PL/SQL, use the DBMS_XMLGEN package to execute any SQL query and map the results into an XML document as a CLOB or XMLType.
  • 57. SYS_XMLGEN() Function Converts its argument into an XML document Accepts two arguments: A scalar value, object type, or XMLType instance An optional XMLFormat() object Returns an XMLType instance Creates and queries XML instances within SQL SELECT SYS_XMLGEN( XMLForest (last_name, salary), XMLFormat('EMPLOYEE')) FROM employees WHERE department_id = 30;
  • 58. SYS_XMLAGG() Function The SYS_XMLAGG() function: Groups all the input documents and produces a single XML document Is used to aggregate (concatenate) fragments SELECT SYS_XMLAGG( SYS_XMLGEN(last_name), XMLFormat('Employees')) result FROM employees WHERE department_id < 30 GROUP BY department_id;
  • 59. DBMS_XMLGEN Creates an XML document from SQL query, XMLType Gets the document as a CLOB Provides a fetch interface Is useful for pagination in Web applications
  • 60. DBMS_XMLGEN (1) CREATE TABLE temp_clob_tab(result CLOB); DECLARE qryCtx DBMS_XMLGEN.ctxHandle; result CLOB; BEGIN qryCtx := DBMS_XMLGEN.newContext('SELECT * FROM hr.employees'); -- Set the row header to be EMPLOYEE DBMS_XMLGEN.setRowTag(qryCtx, 'EMPLOYEE'); -- Get the result result := DBMS_XMLGEN.getXML(qryCtx); INSERT INTO temp_clob_tab VALUES(result); --Close context DBMS_XMLGEN.closeContext(qryCtx); END; /
  • 61. DBMS_XMLGEN (2) RESULT ------------------------------------------------ <?xml version="1.0"?> <ROWSET> <EMPLOYEE> <EMPLOYEE_ID>100</EMPLOYEE_ID> <FIRST_NAME>Steven</FIRST_NAME> <LAST_NAME>King</LAST_NAME> <EMAIL>SKING</EMAIL> <PHONE_NUMBER>515.123.4567</PHONE_NUMBER> <HIRE_DATE>17-JUN-87</HIRE_DATE> <JOB_ID>AD_PRES</JOB_ID> <SALARY>24000</SALARY> <DEPARTMENT_ID>90</DEPARTMENT_ID> </EMPLOYEE> 
 </ROWSET>
  • 62. Create XML data DBMS_XMLDOM SYS _XMLGEN XMLVIEW
  • 64. National LanguageSettings CHARACTER SET: AL32UTF8 NATIONAL CHARACTER SET: AL16UTF16 NLS_LENGTH_SEMANTICS ='BYTE'; Before $ORACLE_HOMEDBMSDMINatqm.sql Avoid “Strange” NLS related errors: Registering an XML Schema via WebDAV, Drag & Drop Registering an XML Schema via BFILENAME
  • 65. Database character set is AL32UTF Client character set is WIN1252. SQL> drop table test; SQL> create table test of xmltype; SQL> insert into test values (xmltype( '<?xml version="1.0" encoding="UTF-8"?><FOO/>')); SQL> select object_value from test; OBJECT_VALUE --------------------------------------------------- <?xml version="1.0" encoding="WINDOWS-1252"?><FOO/> NLS FAQ (1)
  • 66. SQL> select x.object_value.getClobVal() from test x; X.OBJECT_VALUE.GETCLOBVAL() -------------------------------------------- <?xml version="1.0" encoding="UTF-8"?><FOO/> SQL> exit C:EMP>set NLS_LANG=AMERICAN_AMERICA.AL32UTF8 C:EMP>sqlplusscott/tiger SQL> select * from test; SYS_NC_ROWINFO$ -------------------------------------------- <?xml version="1.0" encoding="UTF-8"?><FOO/> NLS FAQ (2)
  • 67. ORA-24247 ORA-24247 Network access denied by access control list, ACL Packages involved (11gR1) UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, UTL_INADDR Solution: DBMS_NETWORK_ACL_ADMIN Check, Add, Remove Privileges
  • 68. Troubleshooting XMLDB Use What You Know: SET AUTOTRACE ON, DBMS_XPLAN.DISPLAY, TKPROF, SQL_TRACE, EVENTS like 10046 etc. Schema Registration: ALTER session SET events = '31098 trace name context forever' Protocol Server: ALTER system SET event = '31098 trace name context forever, level 2' scope=spfile Trace files  UDUMP Directory
  • 69. Small tip regarding “alias” usage Using an alias called: “X”, “Y” (and not Z
) SQL> select * from v$versionwhererownum=1; BANNER --------------------------------------------------------- Oracle Database 10g EnterpriseEdition Release 10.2.0.4.0 SQL> describeX FUNCTION X RETURNS NUMBER Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P ST_POINT IN SQL> describeY FUNCTION Y RETURNS NUMBER Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P ST_POINT IN
  • 70. Reward True understanding Optimal performance Out performing XML (Java) More options from “within” XMLDB: a “No-Cost” option Opening up propriety environments
  • 71.
  • 72. References (1) Oracle XML DB http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16659/toc.htm XML DB OTN / FAQ Thread http://forums.oracle.com/forums/forum.jspa?forumID=34 http://forums.oracle.com/forums/thread.jspa?threadID=410714
  • 73. References (2) Oracle Whitepapers Oracle XML DB : Choosing the Best XMLType Storage Option for Your Use Case (PDF) Oracle XML DB : Best Practices to Get Optimal Performance out of XML Queries (PDF) Blog http://technology.amis.nl/blog http://blog.gralike.com (Dedicated XMLDB blog)

Hinweis der Redaktion

  1. Emp/Dept tables, Foreign/Primary Keys
Showing here ONLY 1 XML document