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

Designing external table functions


Just like external scalar functions, we can also have external table functions. The external table functions return a table and can only be used in the FROM clause of a query. Even though it returns a result set, the association between DB2 and the function is at a row level. In other words, instead of returning all of the rows at a time, a function returns one row at a time. In this recipe, we will see how we can implement external table functions where they are defined in high-level languages.

How to do it...

When an external table function is invoked, it can internally make five types of calls to it. To define an external table function, we can get the entire result in the first call and return one row at each fetch call. Let's see how we can implement this.

As an example, we will create a table function that returns the names and salaries of employees filtered by their work department, which will be passed as an input to the function. We will define the...