Getting started with DB2 app dev

376 585 0
Getting started with DB2 app dev

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

G E T T I N G S T A R T E D W I T H DB2 application development RAUL F. CHONG, XIQIANG JI, PRIYANKA JOSHI, VINEET MISHRA, MIN WEI YAO A book for the community by the community F I R S T E D I T I O N 4 Getting started with DB2 application development First Edition (October 2010) © Copyright IBM Corporation 2010. All rights reserved. IBM Canada 8200 Warden Avenue Markham, ON L6G 1C7 Canada 5 Notices This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not grant you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing IBM Corporation North Castle Drive Armonk, NY 10504-1785 U.S.A. For license inquiries regarding double-byte character set (DBCS) information, contact the IBM Intellectual Property Department in your country or send inquiries, in writing, to: Intellectual Property Licensing Legal and Intellectual Property Law IBM Japan, Ltd. 3-2-12, Roppongi, Minato-ku, Tokyo 106-8711 The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. 6 Getting started with DB2 application development The licensed program described in this document and all licensed material available for it are provided by IBM under terms of the IBM Customer Agreement, IBM International Program License Agreement or any equivalent agreement between us. Any performance data contained herein was determined in a controlled environment. Therefore, the results obtained in other operating environments may vary significantly. Some measurements may have been made on development-level systems and there is no guarantee that these measurements will be the same on generally available systems. Furthermore, some measurements may have been estimated through extrapolation. Actual results may vary. Users of this document should verify the applicable data for their specific environment. Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. All statements regarding IBM's future direction or intent are subject to change or withdrawal without notice, and represent goals and objectives only. This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. COPYRIGHT LICENSE: This information contains sample application programs in source language, which illustrate programming techniques on various operating platforms. You may copy, modify, and distribute these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs. The sample programs are provided "AS IS", without warranty of any kind. IBM shall not be liable for any damages arising out of your use of the sample programs. References in this publication to IBM products or services do not imply that IBM intends to make them available in all countries in which IBM operates. If you are viewing this information softcopy, the photographs and color illustrations may not appear. 7 Trademarks IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at “ Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries. Other company, product, or service names may be trademarks or service marks of others. Table of Contents Preface 15 Who should read this book? 15 How is this book structured? 15 A book for the community 15 Conventions 16 What’s next? 16 About the authors 19 Contributors 20 Acknowledgements 21 Chapter 1 – Introduction to DB2 application development 23 1.1 DB2 application development: The big picture 23 1.2 Server-side development 25 1.2.1 Stored procedures 25 1.2.2 User-defined functions 26 1.2.3 Triggers 26 1.3 Client-side development 27 1.3.1 Embedded SQL 27 1.3.2 Static SQL vs. Dynamic SQL 28 1.3.3 CLI and ODBC 30 1.3.4 JDBC, SQLJ and pureQuery 33 1.3.5 OLE DB 35 1.3.6 ADO.NET 36 1.3.7 PHP 37 1.3.8 Ruby on Rails 38 1.3.9 Perl 38 1.3.10 Python 38 1.4 XML and DB2 pureXML 39 1.5 Web services 40 1.6 Administrative APIs 41 1.7 Development tools 41 1.7.1 Visual Studio 42 1.7.2 Eclipse 42 1.7.3 Access and Excel 42 1.8 Development environments 43 1.8.1 DB2 Offerings on the Cloud 43 1.8.2 DB2 Express-C virtual appliance for VMWare 47 1.9 Sample programs 47 1.10 Exercises 47 1.11 Summary 48 1.12 Review questions 48 Chapter 2 – DB2 pureXML 51 2.1 Using XML with databases 52 10 Getting started with DB2 application development 2.2 XML databases 52 2.2.1 XML-enabled databases 52 2.2.2 Native XML databases 53 2.3 XML in DB2 54 2.3.1 pureXML technology advantages 55 2.3.2 XPath basics 57 2.3.3 XQuery basics 60 2.3.4 Inserting XML documents 62 2.3.5 Querying XML data 65 2.3.6 Joins with SQL/XML 72 2.3.7 Joins with XQuery 73 2.3.8 Update and delete operations 74 2.3.9 XML indexing 76 2.4 Working with XML Schemas 77 2.4.1 Registering your XML Schemas 77 2.4.2 XML Schema validation 80 2.4.3 Other XML support 81 2.5 Exercises 82 2.6 Summary 83 2.7 Review questions 83 Chapter 3 – Stored procedures, UDFs, triggers, and data Web services 85 3.1 Stored procedures: The big picture 85 3.2 Working with IBM Data Studio 87 3.2.1 Creating a project 88 3.2.2 Creating a stored procedure 90 3.3 SQL PL stored procedures basics 94 3.3.1 Stored procedure structure 94 3.3.2 Optional stored procedure attributes 94 3.3.3 Parameters 95 3.3.4 Comments in an SQL PL stored procedure 96 3.3.5 Compound statements 96 3.3.6 Variable declaration 96 3.3.7 Assignment statements 97 3.3.8 Cursors 98 3.3.9 Flow control 98 3.3.10 Errors and condition handlers 99 3.3.11 Calling stored procedures 101 3.3.12 Dynamic SQL 102 3.4 Java Stored Procedures 103 3.5 User-defined functions: The big picture 105 3.5.1 Scalar functions 106 3.5.2 Table functions 107 3.6 Triggers: The big picture 107 3.6.1 Types of triggers 108 [...]... joined with an underscore For example: CREATE TABLE table_name What’s next? We recommend you to review the following books in this book series for more details about related topics:  Getting started with DB2 Express-C  Getting started with IBM Data Studio for DB2Getting started with Java  Getting started with C/C++  Getting started with NET  Getting started with Ruby on Rails  Getting started with. .. started with PHP  Getting started with Perl  Getting started with Python  Getting started with Open source development  Getting started with Eclipse The following figure shows all the different eBooks in the DB2 on Campus book series available for free at ibm.com /db2/ books 17 The DB2 on Campus book series About the authors Raul F Chong is the DB2 on Campus program manager and a DB2 technical evangelist... application 195 5.5.4 Building ODBC/CLI applications 212 5.6 Working with XML in C/C++ applications with DB2 214 5.7 Exercises 214 12 Getting started with DB2 application development 5.8 Summary 214 5.9 Review questions 215 Chapter 6 – Application Development with NET 217 6.1 NET with DB2 applications: The big picture 217 6.2... to queries in the DB2 forum Min Wei Yao is an application developer focusing on Business Intelligence Min Wei joined IBM in 2008 and has been working in the IBM Global Business Services area since then Besides working as a developer, Min Wei also likes to experiment with Linux, and DB2 Min 20 Getting started with DB2 application development Wei is an IBM certified DB2 application developer and administrator... to develop your programs, DB2 software ( "DB2" ) provides the drivers, adapters, and extensions you need to work with databases as part of your application Moreover with DB2 Express-C, you can develop your applications at no cost, with no database size limits, and with the same level of programming language support as the other versions of DB2 Develop once using DB2 Express-C, and you can run on any DB2. .. functions, while, application developers can develop client applications using the programming language of their choice This flexibility is illustrated in Figure 1.1 24 Getting started with DB2 application development Figure 1.1 - DB2 software is for everyone: Database and application developers In Figure 1.1 the left side represents a client machine where an application programmer develops and runs... the PHP environment manually 286 8.3 PHP - DB2 application development 289 8.3.1 PHP extensions to use with DB2 289 8.3.2 PHP development with the ibm _db2 extension 289 8.3.3 PHP development with PDO_IBM/PDO_ODBC 300 8.4 Optimizing DB2 usage with PHP 318 8.4.1 Design considerations for increasing the PHP -DB2 performance 318 8.5 Exercises ... you develop UML diagrams Rational Application Developer (RAD) RAD is an Eclipse-based rapid application development tool for software developers Visual Studio Microsoft® Visual Studio is an IDE that allows you to develop applications in the Windows® platform using Microsoft's technology Aptana Studio This is a free IDE for developing PHP applications Table 1.1 - Tools that can help you develop applications... Application development with Ruby on Rails 249 7.1 Ruby on Rails applications with DB2: The big picture 249 7.2 Setting up the RoR environment 252 7.2.1 Installing Ruby 252 7.2.2 Installing Rails 255 7.2.3 Creating your first RoR application and starting the Web server 256 7.2.4 Working with a DB2 database: The ibm_db gem 258 7.3 Developing RoR applications... managers How is this book structured? This book is closely related to the eBook Getting Started with DB2 Express-C; it expands the application development chapters covered in that book In fact, Chapter 1 and 2 are taken directly from the application development chapters in that book as they provide a good overview of DB2 application development Chapter 3 discusses server-side programming such as stored procedures, . Getting started with DB2 Express-C  Getting started with IBM Data Studio for DB2  Getting started with Java  Getting started with C/C++  Getting started with .NET  Getting started with. with Ruby on Rails  Getting started with PHP  Getting started with Perl  Getting started with Python  Getting started with Open source development  Getting started with Eclipse The following. Exercises 214 12 Getting started with DB2 application development 5.8 Summary 214 5.9 Review questions 215 Chapter 6 – Application Development with .NET 217 6.1 .NET with DB2 applications:

Ngày đăng: 23/04/2014, 23:02

Từ khóa liên quan

Mục lục

  • Preface

    • Who should read this book?

    • How is this book structured?

    • A book for the community

    • Conventions

    • What’s next?

    • About the authors

    • Contributors

    • Acknowledgements

    • Chapter 1 – Introduction to DB2 application development

      • 1.1 DB2 application development: The big picture

      • 1.2 Server-side development

        • 1.2.1 Stored procedures

        • 1.2.2 User-defined functions

        • 1.2.3 Triggers

        • 1.3 Client-side development

          • 1.3.1 Embedded SQL

          • 1.3.2 Static SQL vs. Dynamic SQL

          • 1.3.3 CLI and ODBC

          • 1.3.4 JDBC, SQLJ and pureQuery

          • 1.3.5 OLE DB

          • 1.3.6 ADO.NET

          • 1.3.7 PHP

          • 1.3.8 Ruby on Rails

Tài liệu cùng người dùng

Tài liệu liên quan