Book Image

IBM DB2 9.7 Advanced Application Developer Cookbook

Book Image

IBM DB2 9.7 Advanced Application Developer Cookbook

Overview of this book

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 (15 chapters)
IBM DB2 9.7 Advanced Application Developer Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface

Using XML in a declared temporary table


Starting from DB2 9.7, we can create declared temporary tables with XML columns in them. DGTTs can contain XML data and they can be used just like regular tables.

How to do it...

Let's see how we can create a declared temporary table with an XML columns:

  1. 1. Create a declared temporary table with XML column in it:

    DECLARE GLOBAL TEMPORARY TABLE sample_xml (empno INT,
    sal_rise_date DATE,
    sal_dtls XML)
    ON COMMIT DELETE ROWS
    NOT LOGGED
    IN user_temp_tbsp;
    
    
  2. 2. Insert an XML document in the temporary table. To do that, use the XMLPARSE function. This function converts a serialized string value to an XML document. In case of any errors in the XML document, an error is returned:

    INSERT INTO SESSION.sample_xml
    VALUES(1007,
    CURRENT DATE,
    XMLPARSE(document'<salary_revision sal_dtl_key = "5099">
    <old_salary>
    <monthly_salary>30000</monthly_salary>
    <effective_date>24-11-2010</effective_date>
    </old_salary>
    <new_salary&gt...