You are previewing IBM DB2 9.7 Advanced Application Developer Cookbook.
O'Reilly logo
IBM DB2 9.7 Advanced Application Developer Cookbook

Book Description

This cookbook is essential reading for every ambitious IBM DB2 application developer. With over 70 practical recipes, it will help you master the most sophisticated elements and techniques used in designing high quality DB2 applications.

  • Learn to design secured and robust database applications with this book and ebook.

  • Get to grips with all the important aspects of the DB2 application development life cycle starting with design and planning, moving through the development phase, and getting on to performance tips.

  • Master various new DB2 features for high quality application design.

  • In Detail

    With lots of new features, DB2 9.7 delivers one the best relational database systems in the market. DB2 pureXML optimizes Web 2.0 and SOA applications.

    DB2 LUW database software offers industry leading performance, scale, and reliability on your choice of platform on various Linux distributions, leading Unix Systems like AIX, HP-UX and Solaris and MS Windows platforms.

    This DB2 9.7 Advanced Application Developer Cookbook will provide an in-depth quick reference during any application's design and development.

    This practical cookbook focuses on advanced application development areas that include performance tips and the most useful DB2 features that help in designing high quality applications. This book dives deep into tips and tricks for optimized application performance.

    With this book you will learn how to use various DB2 features in database applications in an interactive way.

    Table of Contents

    1. Copyright
    2. Credits
    3. About the Authors
    4. About the Reviewers
    5. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
        3. Instant Updates on New Packt Books
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Application Development Enhancements in DB2 9.7
      1. Introduction
      2. Changing column names online using the ALTER TABLE operation
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. See also
      3. Using the CREATE OR REPLACE clause while creating objects
        1. Getting ready
        2. How to do it...
        3. How it works…
      4. Using the ALTER TABLE operation in a single transaction
        1. Getting ready
        2. How to do it...
        3. How it works…
      5. Using the CREATE WITH ERROR support
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Using the soft invalidation and automatic revalidation support
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Using the ALTER COLUMN SET DATA TYPE extended support
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      8. Using the new TRUNCATE statement
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      9. Using AUTONOMOUS transactions
        1. How to do it...
        2. How it works…
      10. Using implicit casting during application enablement
        1. Getting ready…
        2. How to do it...
        3. How it works…
        4. There's more…
      11. Using the DEFAULT values and NAMED arguments in procedures
        1. Getting ready
        2. How to do it…
        3. How it works…
    8. 2. DB2 Application Techniques
      1. Introduction
      2. Granting and revoking instance-level authorities
        1. Getting ready
        2. How to do it...
          1. Granting instance-level authorities
          2. Revoking authorities
        3. How it works....
        4. There's more...
          1. What changed in DB2 9.7
      3. Granting and revoking database-level authorities
        1. Getting ready
        2. How to do it...
          1. Granting database-level authorities
          2. Revoking authorities
        3. How it works...
        4. There's more…
      4. Granting and revoking object privileges
        1. Getting ready
        2. How to do it...
          1. Granting privileges
          2. Revoking privileges
        3. There's more…
      5. Implementing static SQL in DB2
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more…
      6. Implementing dynamic SQL in DB2
        1. How to do it...
        2. How it works...
        3. There's more…
          1. Statement concentrator for dynamic SQL
          2. Choosing between static and dynamic SQL
      7. Creating Declared Global Temporary Tables (DGTTs)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Referencing a declared global temporary table
          2. Dropping a declared temporary table
          3. Using declared temporary tables across transactions
          4. Using Admin views to view temporary tables information
      8. Using XML in a declared temporary table
        1. How to do it...
        2. How it works…
        3. There's more…
      9. Improving performance by creating indexes on a DGTT
        1. How to do it...
        2. How it works…
        3. There's more…
      10. Creating Created Global Temporary Tables (CGTT)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
          1. Referencing a CGTT
          2. Dropping a CGTT
      11. Using generated columns in tables
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
          1. LOAD and IMPORT considerations for generated columns
          2. Using a generated column as range partitioning key
          3. Using generated columns as MDC dimensions
          4. Using generated columns for performance
      12. Creating a savepoint
        1. How to do it...
        2. How it works...
        3. There's more…
      13. Rolling back to a savepoint
        1. How to do it...
      14. Using savepoints in JDBC
        1. Getting ready…
        2. How to do it…
      15. Using savepoints in SQLJ
        1. Getting ready…
        2. How to do it…
      16. Creating a sequence object
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
      17. Modifying a sequence object
        1. Getting ready
        2. How to do it...
        3. How it works…
      18. Referencing a sequence object
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more…
    9. 3. General Application Design
      1. Introduction
      2. Improving concurrency by using a connection concentrator
        1. Getting ready
        2. How to do it
        3. How it works...
        4. There's more...
          1. Differences between connection pooling and the connection concentrator
      3. Using trusted contexts for improved security
        1. Getting ready
        2. How to do it
        3. How it works...
          1. Acquiring role membership through a trusted context
          2. Enhancing performance
          3. Altering a trusted context
      4. Using trusted connections in JDBC
        1. Getting ready
        2. How to do it
        3. How it works...
      5. Using trusted connections in PHP
        1. Getting ready
        2. How to do it...
      6. Securing data by using DB2 encryption
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Improving concurrency by using enhanced optimistic locking
        1. How to do it...
        2. How it works
        3. There's more...
      8. Working with user-defined types (UDT)
        1. How to do it...
        2. There's more…
      9. Working with structured types
        1. Getting ready
        2. How it works...
          1. Dropping typed tables
          2. Defining constraints on object identifier columns
    10. 4. Procedures, Functions, Triggers, and Modules
      1. Introduction
      2. Creating a simple stored procedure
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more
          1. Stored procedure execution
          2. Calling a stored procedure
          3. Using named parameters
      3. Using dynamic SQL in stored procedures
        1. How to do it...
        2. How it works...
      4. Working with result sets in stored procedures
        1. How to do it...
        2. How it works...
        3. There's more…
      5. Using ARRAY objects in stored procedures
        1. How to do it...
        2. There's more…
          1. Using procedures with ARRAY parameters in Java
      6. Handling errors in stored procedures
        1. How to do it...
        2. How it works...
      7. Designing external stored procedures
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
          1. Parameter styles in external stored procedures
      8. Using PL/SQL exception handling in a procedure
        1. How to do it...
        2. How it works...
        3. There's more…
          1. Explicitly raising an exception
      9. Working with the message buffer in stored procedures
        1. Getting ready
        2. How to do it…
        3. How it works...
      10. Planning and designing triggers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
          1. Modifying and dropping triggers
      11. Using scalar user-defined functions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
          1. Restrictions on user-defined functions
      12. Writing external user-defined functions
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Using scratchpad in external functions
      13. Designing external table functions
        1. How to do it...
        2. How it works...
      14. Working with modules in DB2
        1. Getting ready
        2. How to do it
        3. How it works
        4. There's more…
          1. Module privileges
          2. Object name resolution
    11. 5. Designing Java Applications
      1. Introduction
      2. Creating connection objects in JDBC applications
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
      3. Creating connection objects in SQLJ applications
        1. Getting ready
        2. How to do it...
          1. How it works...
            1. Java packages for SQLJ applications
      4. Manipulating XML Data in Java applications
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
      5. Batch processing in JDBC applications
        1. Getting ready
        2. How to do it...
          1. Running SQL multiple times with different values for parameter markers
            1. Running multiple SQL statements in a batch
            2. How it works...
            3. There's more...
              1. Restrictions on executing statements in a batch
      6. Batch processing in SQLJ applications
        1. Getting ready
        2. How to do it...
          1. How it works...
      7. Working with scrollable result sets
        1. Getting ready
        2. How to do it ...
          1. How it works...
          2. There's more...
            1. Using scrollable iterators in SQLJ applications
      8. Handling errors and warnings in JDBC applications
        1. Getting ready
        2. How to do it...
          1. How it works...
            1. Handling SQL warnings
            2. Using SQLException subclasses
      9. Developing Java applications for high availability
        1. Getting ready
        2. How to do it...
          1. Configuring an automatic client reroute
            1. Configuring client affinity
            2. Workload balancing by using DB2 pureScale
          2. How it works...
            1. Automatic client rerouting
            2. Workload balancing in a pureScale environment
      10. Using SSL in Java applications
        1. Getting ready
        2. How to do it...
          1. Step 1: Configuring JRE for SSL Support
            1. Step 2: Setting up the server environment
            2. Step 3: Setting up the client environment
            3. Step 4: Configuring connections to use SSL
          2. How it works...
    12. 6. DB2 9.7 Application Enablement
      1. Introduction
      2. First step towards enabling Oracle application to DB2 9.7
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more...
      3. Using ROWNUM and DUAL in DB2 9.7
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more…
      4. Using CUR_COMMIT concurrency control isolation level
        1. Getting ready
        2. How to do it...
        3. How it works…
      5. Implementing hierarchical queries for recursion support
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Using PL/SQL ANONYMOUS block statements
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
      7. Handling RAISE_APPLICATION_ERROR in DB2 PL/SQL
        1. Getting ready
        2. How to do it...
        3. How it works…
      8. Migrating Oracle database objects on to DB2 9.7
        1. Getting ready
        2. How to do it...
        3. How it works…
      9. Porting multi-action triggers from Oracle to DB2 9.7
        1. Getting ready
        2. How to do it...
        3. How it works…
    13. 7. Advanced DB2 Application Features and Practices
      1. Introduction
      2. Working with OLAP functions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Other ways of defining an OLAP window
      3. Using optimizer profiles
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Examples of optimization profiles
            1. List of guidelines available
      4. Using explain utilities
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Capturing explain information for a routine
          2. Explain tables
      5. Using section explain information
        1. Getting ready
        2. How to do it...
        3. How it works
        4. There's more...
      6. Interpreting db2exfmt output
        1. How to do it...
        2. How it works
        3. There's more...
          1. Understanding optimizer joins
          2. Operators in an access plan
      7. Application development in partitioned databases
        1. How to do it
        2. There's more
          1. Database partitioning feature
          2. Range partitioning
          3. Multidimensional clustering
          4. Putting everything together
    14. 8. Preparing and Monitoring Database Applications
      1. Introduction
      2. Preparing applications for execution
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Understanding the consistency token
        4. There's more...
          1. Advantages of deferred binding
          2. Packages and SQL routines
      3. Rebinding existing packages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Customizing application behavior using registry variables
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Monitoring application performance
        1. How to do it...
        2. How it works...
    15. 9. Advanced Performance Tuning Tips
      1. Introduction
      2. Understanding predicates in SQL statements
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Improving INSERT performance
        1. Getting Ready
        2. How to do it...
        3. How it works...
      4. Writing effective SQL statements
        1. Getting Ready
        2. How to do it...