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]

Leverage the power of SQL Procedural Language on DB2 for Linux, UNIX, Windows, i5/OS, and z/OS

Information, sample code, and sample chapter

Zamil Janmohamed, Clara Liu, Drew Bradstock, Raul Chong, Michael Gao, Fraser McArthur, and Paul Yip comprise the DB2 SQL PL 2nd Edition book team. They are all experienced in supporting DB2 application development for IBM business partners and individually have written many articles for developerWorks DB2.

Summary:  Want to write portable and efficient SQL PL code on Linux, UNIX®, Windows®, i5/OS™, and z/OS®? Search no more, start with the new book - DB2 SQL PL: Essential Guide for DB2 UDB on Linux, UNIX, Windows, i5/OS, and z/OS.

Date:  16 Dec 2004
Level:  Introductory

Activity:  6474 views
Comments:  

DB2 SQL Procedural Language

DB2 SQL Procedural Language (SQL PL) is a subset of the SQL Persistent Stored Modules (SQL/PSM) language standard. This standard is the basis for the structured programming languages used with SQL to write stored procedures, functions, triggers, and standalone code. Encapsulating complex business logic in database stored procedures can yield the following benefits:

  • Significantly improved application performance
  • Increased application scalability
  • Simplified application development
  • Reduced network traffic

The SQL/PSM standard combines the ease of data access of SQL with the flow control structures of a simple programming language. It gives developers the ability to create compound SQL statements and procedures that only need to be coded once to run on multiple platforms.


DB2 SQL PL: Essential Guide for DB2 UDB on Linux, UNIX, Windows, i5/OS, and z/OS

SQL PL book cover

Learning how to write SQL PL code that can run on DB2 for Linux, UNIX, Windows, i5/OS, and z/OS can improve the portability of your code. Read a sample chapter from the new book DB2 SQL PL: Essential Guide for DB2 UDB on Linux, UNIX, Windows, i5/OS, and z/OS.

Download Chapter 2 of the book and learn about the basic SQL procedure structure on all these platforms. In this chapter, you will learn:

  • The fundamental structure of an SQL procedure
  • The various clauses for the CREATE PROCEDURE statement
  • The structure of the procedure body
  • The statements that can be coded in the procedure body

Try the sample code

Download sample code for Chapter 2. Follow the examples and create the stored procedures in your own environment.

This edition of the book includes DB2 SQL PL improvements that will be introduced as part of the next point release of DB2 for Linux, Unix, and Windows, as well as the DB2 SQL PL implementation on i5/OS and z/OS. Various methods to resolve performance issues are introduced in the book. For example, you will learn how to monitor and identify bottlenecks and resolve them using a number of alternative methods.

This book teaches the reader through concrete examples and thorough discussions how to set up the development environment and use all the language elements of the latest SQL PL. Expert tips and best practices for achieving optimal performance and code manageability are also included. In addition, you'll find this book to be a valuable reference for SQL PL code syntax and troubleshooting.

Table of contents

Chapter 1Introduction
Chapter 2Basic SQL Procedure Structure
Chapter 3Overview of SQL PL Language Elements
Chapter 4Using Flow of Control Statements
Chapter 5Understanding and Using Cursors and Result Sets
Chapter 6Condition Handling
Chapter 7Working with Dynamic SQL
Chapter 8Nested SQL Procedures
Chapter 9User-Defined Functions and Triggers
Chapter 10Leveraging DB2 Application Development Features
Chapter 11Deploying SQL Procedures, Functions, and Triggers
Chapter 12Performance Tuning
Chapter 13Best Practices
Appendix AGetting Started with DB2
Appendix BInline SQL PL for DB2 UDB for Linux, UNIX, and Windows
Appendix CBuilding from the Command Line
Appendix DUsing the DB2 Development Center
Appendix ESecurity Considerations in SQL Procedures
Appendix FDDL
Appendix GAdditional Resources
Appendix HSample Application Code

Updates, clarifications, and corrections

Click here for updates and corrections for the book DB2 SQL PL: Essential Guide for DB2 UDB on Linux, UNIX, Windows, i5/OS, and z/OS.

How to order

ISBN of this book is 0131477005. It can be ordered online from any major online bookseller, or from the IBM Book Store.



Downloads

DescriptionNameSizeDownload method
Chapter 2Chapter2.pdf148 KB FTP |HTTP
Sample codesampleCode_Chapter2.zip7 KB FTP | HTTP

Information about download methods          Get Adobe® Reader®


Resources

About the author

Zamil Janmohamed, Clara Liu, Drew Bradstock, Raul Chong, Michael Gao, Fraser McArthur, and Paul Yip comprise the DB2 SQL PL 2nd Edition book team. They are all experienced in supporting DB2 application development for IBM business partners and individually have written many articles for developerWorks DB2.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

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.

Choose your display name

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.

(Must be between 3 – 31 characters.)

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

 


Rate this article

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=32368
ArticleTitle=Leverage the power of SQL Procedural Language on DB2 for Linux, UNIX, Windows, i5/OS, and z/OS
publish-date=12162004
author1-email=db2sqlpl@ca.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers