Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Book Excerpt: DB2 SQL Procedural Language for Linux, UNIX, and Windows

Drew Bradstock (drewkb@ca.ibm.com), DB2 Consultant, IBM Toronto Lab
Drew Bradstock is a database consultant at the IBM Toronto Lab.
Hana Curtis (hcurtis@ca.ibm.com), DB2 Developer, IBM Canada
Hana Curtis has many years experience in relational database technology and is currently a member of the DB2 development team at the IBM Toronto Laboratory. In the past, she has worked at the DB2 Integration Center and also as a database consultant assisting IBM Business Partners to enable their applications to DB2. Hana has written several articles and is also one of the authors of the book DB2 SQL Procedural Language for Linux, UNIX, and Windows (Prentice Hall, 2003).
Michael Gao (xmgao@ca.ibm.com), DB2 UDB Consultant, IBM Toronto Lab
Michael Gao is a DB2 Consultant from the IBM Toronto Lab where DB2 for distributed platforms is developed. He currently primarily works with IBM business partners in performance tuning, application development, porting and customized education. He has presented at several international conferences and co-authored the book DB2 SQL Procedural Language for Windows, UNIX and Linux. You can reach Michael at xmgao at ca.ibm.com.
Zamil Janmohamed (zamil@ca.ibm.com), DB2 Consultant, IBM Toronto Lab
Zamil Janmohamed is a database consultant at the IBM Toronto Lab.
Clara Liu (claraliu@ca.ibm.com), Database Consultant, IBM Toronto
Clara Liu works as a DB2 UDB consultant at the IBM Toronto Laboratory. As a member of the Data Management Channel Development Team, she works closely with IBM business partners. Clara specializes in database application development and integration of new technologies with DB2. She teaches DB2 UDB certification courses to IBM business partners and at conferences. She co-authored several books which can be found at your favorite online bookstore.
Fraser McArthur (fgmcarth@ca.ibm.com), DB2 Consultant, EMC
Photo: Fraser McArthur
Fraser McArthur is a consultant at the IBM Toronto Lab, where DB2 UDB for distributed platforms (Windows/Unix) is developed. He is a member of the Data Management Partner Enablement organization where he works with IBM Business Partners to migrate applications to DB2 and perform performance tuning. Fraser is a DB2 Certified Solutions Expert in both DB2 Administration and Application Development.
Paul Yip (ypaul@ca.ibm.com), DB2 Consultant, IBM Toronto Software Lab
Author photo
Paul Yip is a consultant from the IBM Toronto Lab. He specializes in assisting business partners port their database applications from competitor's platforms to DB2. He has authored over a dozen technical articles and has co-authored three books.

Summary:  DB2 SQL Procedural Language is an easy-to-learn language that can be used to write stored procedures, triggers, and user-defined functions in DB2. This comprehensive guide, written by experts who have worked with the language from the beginning, is filled with examples and tips to help you get started as quickly as possible.

Date:  11 Jul 2005 (Published 01 Sep 2002)
Level:  Introductory

Activity:  2068 views
Comments:  

DB2 SQL Procedural Language is an easy-to-learn language that can be used to write stored procedures, triggers, and user-defined functions in DB2. This comprehensive guide, written by experts who have worked with the language from the beginning, is filled with examples and tips to help you get started as quickly as possible.

About this book

SQL Procedural Language book cover

DB2 SQL Procedural Language for Linux, UNIX, and Windows fills the need for a comprehensive guide on writing database applications using SQL Procedural Language (SQL PL). SQL PL is an easy-to-learn language that can be used to write stored procedures, triggers, and user-defined functions in DB2. Written by experts from the IBM Toronto Lab (where DB2 for Linux, UNIX, and Windows is developed) who have worked with the language from the beginning, this book is filled with examples and expert tips to help you get started as quickly as possible.

Table of contents

Chapter 1 - Introduction
Chapter 2 - Basic SQL Procedure Structure
Chapter 3 - Using Flow-of-Control Statements
Chapter 4 - Understanding and Using Cursors
Chapter 5 - Condition Handling
Chapter 6 - Working with Dynamic SQL
Chapter 7 - Working with Nested SQL Procedures
Chapter 8 - Leveraging DB2 Advanced Features
Chapter 9 - Deploying Stored Procedures
Chapter 10 - Working with Triggers and User-Defined Functions
Appendix A - Getting Started with DB2
Appendix B - Setting Up the Build Environment
Appendix C - Using the Development Center
Appendix D - Security Considerations in SQL Stored Procedures
Appendix E - Built-in Function Reference
Appendix F - DDL
Appendix G - Additional Resources
Appendix H - Sample Application Code for Receiving Cursor Result Sets
Appendix I - SQL PL Cross Platform Compatibility

How to order

You can order the book using the following ISBN: 0-13-100772-6

Sample download: Chapter 5. Exception Handling

In this chapter, you will learn:

  • What SQLCODE and SQLSTATE are, and the differences between them.
  • What a condition handler is, when to use it, and how to work with multiple handlers.
  • How to force an application or user-defined error, and how to set the appropriate message tag to go along with it.
  • Various ways of returning errors, and how to check the success and or failure of a stored procedure call.

Related information


Download

DescriptionNameSizeDownload method
Chapter in PDF formatch05.pdf646 KBFTP|HTTP

Information about download methods          Get Adobe® Reader®


Biographies

Drew Bradstock is a database consultant at the IBM Toronto Lab.

Hana Curtis has many years experience in relational database technology and is currently a member of the DB2 development team at the IBM Toronto Laboratory. In the past, she has worked at the DB2 Integration Center and also as a database consultant assisting IBM Business Partners to enable their applications to DB2. Hana has written several articles and is also one of the authors of the book DB2 SQL Procedural Language for Linux, UNIX, and Windows (Prentice Hall, 2003).

Michael Gao is a DB2 Consultant from the IBM Toronto Lab where DB2 for distributed platforms is developed. He currently primarily works with IBM business partners in performance tuning, application development, porting and customized education. He has presented at several international conferences and co-authored the book DB2 SQL Procedural Language for Windows, UNIX and Linux. You can reach Michael at xmgao at ca.ibm.com.

Zamil Janmohamed is a database consultant at the IBM Toronto Lab.

Clara Liu works as a DB2 UDB consultant at the IBM Toronto Laboratory. As a member of the Data Management Channel Development Team, she works closely with IBM business partners. Clara specializes in database application development and integration of new technologies with DB2. She teaches DB2 UDB certification courses to IBM business partners and at conferences. She co-authored several books which can be found at your favorite online bookstore.

Photo: Fraser McArthur

Fraser McArthur is a consultant at the IBM Toronto Lab, where DB2 UDB for distributed platforms (Windows/Unix) is developed. He is a member of the Data Management Partner Enablement organization where he works with IBM Business Partners to migrate applications to DB2 and perform performance tuning. Fraser is a DB2 Certified Solutions Expert in both DB2 Administration and Application Development.

Author photo

Paul Yip is a consultant from the IBM Toronto Lab. He specializes in assisting business partners port their database applications from competitor's platforms to DB2. He has authored over a dozen technical articles and has co-authored three books.

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=127023
SummaryTitle=Book Excerpt: DB2 SQL Procedural Language for Linux, UNIX, and Windows
publish-date=07112005
author1-email=drewkb@ca.ibm.com
author1-email-cc=
author2-email=hcurtis@ca.ibm.com
author2-email-cc=
author3-email=xmgao@ca.ibm.com
author3-email-cc=
author4-email=zamil@ca.ibm.com
author4-email-cc=
author5-email=claraliu@ca.ibm.com
author5-email-cc=
author6-email=fgmcarth@ca.ibm.com
author6-email-cc=
author7-email=ypaul@ca.ibm.com
author7-email-cc=