Lesson 17 Building Xqueries in Xquery Editor View
Total Page:16
File Type:pdf, Size:1020Kb
AquaLogic Data Services Platform™ Tutorial: Part II A Guide to Developing BEA AquaLogic Data Services Platform (DSP) Projects Note: This tutorial is based in large part on a guide originally developed for enterprises evaluating Data Services Platform for specific requirements. In some cases illustrations, directories, and paths reference Liquid Data, the previous name of the Data Services Platform. Version: 2.1 Document Date: June 2005 Revised: June 2006 Copyright Copyright © 2005, 2006 BEA Systems, Inc. All Rights Reserved. Restricted Rights Legend This software and documentation is subject to and made available only pursuant to the terms of the BEA Systems License Agreement and may be used or copied only in accordance with the terms of that agreement. It is against the law to copy the software except as specifically allowed in the agreement. This document may not, in whole or in part, be copied photocopied, reproduced, translated, or reduced to any electronic medium or machine readable form without prior consent, in writing, from BEA Systems, Inc. Use, duplication or disclosure by the U.S. Government is subject to restrictions set forth in the BEA Systems License Agreement and in subparagraph (c)(1) of the Commercial Computer Software- Restricted Rights Clause at FAR 52.227-19; subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, subparagraph (d) of the Commercial Computer Software--Licensing clause at NASA FAR supplement 16-52.227-86; or their equivalent. Information in this document is subject to change without notice and does not represent a commitment on the part of BEA Systems. THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, BEA Systems DOES NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE, OR THE RESULTS OF THE USE, OF THE SOFTWARE OR WRITTEN MATERIAL IN TERMS OF CORRECTNESS, ACCURACY, RELIABILITY, OR OTHERWISE. Trademarks or Service Marks BEA, BEA Liquid Data for WebLogic, BEA WebLogic Server, Built on BEA, Jolt, JoltBeans, SteelThread, Top End, Tuxedo, and WebLogic are registered trademarks of BEA Systems, Inc. BEA Builder, BEA Campaign Manager for WebLogic, BEA eLink, BEA Manager, BEA MessageQ, BEA WebLogic Commerce Server, BEA WebLogic Enterprise, BEA WebLogic Enterprise Platform, BEA WebLogic Enterprise Security, BEA WebLogic Express, BEA WebLogic Integration, BEA WebLogic Java Adapter for Mainframe, BEA WebLogic JDriver, BEA WebLogic JRockit, BEA WebLogic Log Central, BEA WebLogic Personalization Server, BEA WebLogic Platform, BEA WebLogic Portal, BEA WebLogic Server Process Edition, BEA WebLogic WorkGroup Edition, BEA WebLogic Workshop, and Liquid Computing are trademarks of BEA Systems, Inc. BEA Mission Critical Support is a service mark of BEA Systems, Inc. All other company and product names may be the subject of intellectual property rights reserved by third parties. All other trademarks are the property of their respective companies. Data Services Platform: Samples Tutorial 2 Contents AQUALOGIC DATA SERVICES PLATFORM™ TUTORIAL: PART II ..................... 1 A Guide to Developing BEA AquaLogic Data Services Platform (DSP) Projects ................................1 Lesson 17 Building XQueries in XQuery Editor View ......................................................................10 Lab 17.1 Importing Schemas for Query Development .......................................................................................11 Lab 17.2 Creating Source-to-Target Mappings...................................................................................................11 Lab 17.3 Creating a Basic Parameterized Function ............................................................................................14 Lab 17.4 Creating a String Function with a Built-In XQuery Function..............................................................18 Lab 17.5 Creating a Date Function .....................................................................................................................21 Lab 17.6 Creating Outer Joins and Order By Expressions..................................................................................23 Lab 17.7 Creating Group By and Aggregate Expressions ..................................................................................28 Lab 17.8 Creating Constant Expressions ............................................................................................................32 Lesson 18 Building XQueries in Source View ....................................................................................35 Lab 18.1 Creating a New XML Type .................................................................................................................36 Lab 18.2 Creating a Basic Parameterized XQuery .............................................................................................37 Lab 18.3 Creating a String Function...................................................................................................................40 Lab 18.4 Building an Outer Join and Using Order By........................................................................................44 Lab 18.5 Creating an Inner Join and a Top N......................................................................................................47 Lab 18.6 Creating a Multi-Level Group By........................................................................................................51 Lab 18.7 Using If-Then-Else ..............................................................................................................................54 Lab 18.8 Creating a Union and Concatenation ...................................................................................................58 Lesson 19 Implementing Relationship Functions and Logical Modeling ........................................62 Lab 19.1 Implementing and Testing a Relationship Function ............................................................................63 Lab 19.2 Creating a Model Diagram for Logical Data Services.........................................................................65 Lesson 20 Running Ad Hoc Queries....................................................................................................69 Lab 20.1 Creating an Instance of the PreparedExpression Class ........................................................................69 Lab 20.2 Defining Ad Hoc Query Parameters ....................................................................................................71 Lab 20.3 Testing the Ad Hoc Query...................................................................................................................72 Lesson 21 Creating Data Services Based on SQL Statements ..........................................................74 Lab 21.1 Creating a Data Service from a User-Defined SQL Statement............................................................74 Lab 21.2 Testing Your SQL Data Service ..........................................................................................................76 Data Services Platform: Samples Tutorial 3 Lesson 22 Performing Custom Data Manipulation Using Update Override...................................77 Lab 22.1 Creating an Update Override ...............................................................................................................78 Lab 22.2 Associating an Update Override to a Logical Data Service.................................................................80 Lab 22.3 Testing the Update Override................................................................................................................80 Lesson 23 Updating Web Services Using Update Override ..............................................................82 Lab 23.1 Creating an Update Override for a Physical Data Service...................................................................83 Lab 23.2 Writing Web Service Update Logic in the Update Override ...............................................................84 Lab 23.3 Testing the Update Override................................................................................................................84 Lab 23.4 Checking for Change Requirements ....................................................................................................86 Lesson 24 Understanding Query Plans ...............................................................................................87 Lab 24.1 Viewing the Query Plan.......................................................................................................................88 Lab 24.2 Locating the SQL Statement in a Query Plan ......................................................................................89 Lab 24.3 Locating XML Elements .....................................................................................................................90 Lesson 25 Reusing XQuery Code through Vertical View Unfolding ...............................................91 Lab 25.1 Unfolding Vertical View .....................................................................................................................91 Lab 25.2 Testing a Vertical File Unfolding ........................................................................................................94 Lesson 26 Configuring Alternatives for Unavailable Data Sources