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

by ; ; ; ; ; ;
Edition: 2nd
Format: Hardcover w/CD
Pub. Date: 2005-01-01
Publisher(s): IBM Press
List Price: $70.99

Rent Textbook

Select for Price
There was a problem. Please try again later.

New Textbook

We're Sorry
Sold Out

Used Textbook

We're Sorry
Sold Out

eTextbook

We're Sorry
Not Available

This item is being sold by an Individual Seller and will not ship from the Online Bookstore's warehouse. The Seller must confirm the order within two business days. If the Seller refuses to sell or fails to confirm within this time frame, then the order is cancelled.

Please be sure to read the Description offered by the Seller.

Summary

Straight from IBM - the ultimate DB2 PL SQL resource and the FIRST and ONLY to cover DB2 UDB 8.2!

Table of Contents

Foreword xxi
Introduction
1(10)
Installing DB2
2(1)
History of Stored Procedures
2(1)
A Brief Introduction to Stored Procedures, Triggers, and Functions
3(1)
What's New in the Second Edition
4(3)
DB2's SQL Procedural Language (SQL PL)
5(1)
Other Stored Procedure Languages
5(1)
SQL PL Development Tools---DB2 Development Center
6(1)
Book Conventions
7(4)
Syntax Description
7(2)
Meanings of Style
9(1)
Book Structure
9(1)
Contacting the Authors
9(2)
Basic SQL Procedure Structure
11(26)
The Create Procedure Statement
11(9)
Procedure Name
13(1)
Parameters
14(2)
Specific Name
16(1)
Dynamic Result Sets
17(1)
Contains SQL, Reads SQL Data, Modifies SQL Data
18(1)
Deterministic or Not Deterministic
18(1)
Called on Null Input
18(1)
Inherit Special Registers
18(1)
Old Savepoint Level, New Savepoint Level
18(1)
Language SQL
19(1)
External Action or No External Action
19(1)
Parameter CCSID
19(1)
SQL Procedure Body
20(1)
The SQL Procedure Body Structure
20(8)
Comments
21(1)
Variables
22(1)
Setting Variables
23(1)
DB2 Special Registers
24(4)
Bringing It All Together Example
28(2)
DB2 UDB for iSeries Considerations
30(2)
Fenced and Not Fenced
31(1)
Commit on Return
32(1)
Set Option Statement
32(1)
DB2 UDB for zSeries Considerations
32(4)
Fenced
34(1)
No DBInfo
34(1)
No Collid or Collid collection-id
34(1)
WLM Environment
35(1)
ASUTIME
35(1)
Stay Resident
35(1)
Program Type
35(1)
Security
35(1)
Run Options
35(1)
Commit on Return
36(1)
Stop After System Default Failures or Continue After Failure
36(1)
Summary
36(1)
Overview of SQL PL Language Elements
37(26)
DB2 Data Types
38(3)
Valid DB2 Built-In Data Types and Their Value Ranges
38(3)
Large Objects
41(1)
Choosing Proper Data Types
42(1)
Working with User-Defined Distinct Types
43(2)
Data Manipulation
45(2)
Working with Dates and Times
45(1)
Working with Strings
46(1)
Working with Generated Columns
47(2)
Working with Identity Columns and Sequence Objects
49(12)
Identity Column
50(7)
Sequence Object
57(4)
Platform Portability Considerations
61(1)
Summary
62(1)
Using Flow of Control Statements
63(30)
Compound Statements
64(6)
Not Atomic Compound Statement
66(1)
Atomic Compound Statement
67(1)
Using Labels
68(2)
Conditional Statements
70(6)
The If Statement
70(3)
The Case Statement
73(3)
Looping Statements
76(7)
For Loop
77(2)
While Loop
79(2)
Repeat Loop
81(1)
Loop
82(1)
Transfer of Control Statements
83(9)
Goto
83(2)
Leave
85(2)
Iterate
87(2)
Return
89(1)
Commit
90(1)
Rollback
91(1)
Summary
92(1)
Understanding and Using Cursors and Result Sets
93(32)
Using Cursors in SQL Procedures
94(4)
Positioned Delete
98(2)
Positioned Update
100(2)
Selecting Data from Update, Insert, or Delete Statements
102(4)
Cursor Behavior with Commit/Rollback
106(6)
Save Points Within Procedures
110(2)
Using Cursors to Return Result Sets
112(3)
Returning Multiple Result Sets
115(1)
Cursors and Locking
116(7)
Lock Modes
116(1)
Isolation Levels
116(3)
Controlling Locking in DB2 LUW
119(2)
Controlling Locking in DB2 UDB for iSeries
121(1)
Controlling Locking in DB2 UDB for zSeries
122(1)
DB2 UDB for iSeries Considerations
123(1)
Declare Cursor Statement in DB2 UDB for iSeries
123(1)
Summary
124(1)
Condition Handling
125(50)
Basic Error Checking: SQLCODE and SQLSTATE
125(2)
Condition Handlers
127(7)
Custom Errors and Error Messages
134(15)
Using Signal to Force the Invocation of a Handler
134(4)
Using Resignal to Force the Invocation of a Handler
138(3)
Scope of Handlers
141(2)
Raise_Error Function
143(2)
Get Diagnostics
145(4)
Processing Results from Called Procedures
149(3)
Bringing It All Together
152(3)
DB2 UDB for iSeries Considerations
155(9)
Signal and Resignal Statements
155(2)
Raise_Error function
157(1)
Get Diagnostics
158(6)
DB2 UDB for zSeries Considerations
164(9)
Condition Handlers
164(1)
Get Diagnostics Statement
165(5)
Return Statement
170(3)
Summary
173(2)
Working with Dynamic SQL
175(18)
Prepare and Execute: The Two Phases of Any SQL Statement
176(1)
Dynamic SQL Versus Static SQL
176(1)
Restrictions and Considerations
177(3)
Using Dynamic SQL with Execute Immediate
180(2)
Escaping Single Quotes (')
182(1)
Reusing Dynamic SQL Statements with PREPARE and EXECUTE
182(4)
Using Dynamic SQL in Cursors
186(3)
Dynamic Call Statements
189(3)
Authorization Consideration
192(1)
Summary
192(1)
Nested SQL Procedures
193(22)
Basic Nested SQL Procedures
194(1)
Passing Parameters Between Nested SQL Procedures
195(1)
Returning Values from Nested SQL Procedures
195(2)
Returning Result Sets from Nested SQL Procedures
197(11)
Returning Result Sets to the Client
199(2)
Returning Result Sets to the Caller
201(2)
Receiving Result Sets as a Caller
203(3)
Receiving Multiple Result Sets as a Caller
206(2)
Receiving Results from a Procedure in a Trigger
208(3)
Levels of Nesting
211(2)
Recursion
211(2)
Security
213(1)
Summary
213(2)
User-Defined Functions and Triggers
215(56)
The Create Function Statement
216(6)
Function Name and Parameters
217(2)
Returns Function Output
219(1)
Specific Name
219(1)
Language SQL
219(1)
Deterministic or Not Deterministic
220(1)
External Action or No External Action
220(1)
Contains SQL, Reads SQL Data, Modifies SQL Data
220(1)
Static Dispatch
221(1)
Called On Null Input
221(1)
Inherit Special Registers (LUW and iSeries Only)
221(1)
Predicates (LUW only)
221(1)
SQL Function Body
221(1)
User-Defined Functions by Examples
222(13)
A Simple Scalar UDF Example
222(1)
A Complex Scalar UDF Example
223(3)
A Table UDF Example (LUW and iSeries)
226(4)
Invoking SQL Procedures in UDFs (LUW and iSeries Only)
230(5)
The Create Trigger Statement
235(5)
Trigger Name
237(1)
Before, After, or Instead Of
237(1)
Insert, Delete, or Update
238(1)
Referencing Clauses
239(1)
For Each Row or For Each Statement
239(1)
Mode DB2SQL
240(1)
Triggered Action
240(1)
Triggers by Examples
240(16)
A Before Trigger Example
240(2)
An After Trigger Example
242(4)
A Complex After Trigger Example
246(1)
An Instead Of Trigger Example (for LUW Only)
247(3)
A Comparison of View Triggers and Table Triggers (LUW only)
250(2)
Invoking UDFs and SQL Procedures from Triggers
252(4)
Considerations for Invoking SQL Procedures from UDFs and Triggers
256(7)
Data Access Restrictions
256(1)
Transaction Control in SQL Procedures
257(5)
Table Read or Write Conflict in SQL Procedures on LUW
262(1)
DB2 for iSeries Considerations
263(2)
DB2 for zSeries Considerations
265(3)
The Create Function Statement
265(1)
Trigger Considerations
266(2)
Invoking UDFs and SQL Procedures from Triggers
268(1)
Nesting SQL Statements
268(1)
Summary
268(3)
Leveraging DB2 Application Development Features
271(28)
Leveraging Advanced SQL
272(9)
Combining Select with Insert, Update, and Delete
272(9)
Declared Global Temporary Tables
281(9)
Introduction to Temporary Tables
281(1)
Creating the Environment for Temporary Tables
281(1)
Declaring Global Temporary Tables
282(4)
Using Temporary Tables in SQL Procedures
286(1)
Sharing Temporary Tables Between Multiple Procedures
287(3)
Considerations
290(1)
Created Global Temporary Tables
290(1)
Working with Save Points
290(5)
Introduction to Application Save Points
291(1)
Using Save Points in SQL Procedures
292(3)
Sequence Objects
295(3)
Summary
298(1)
Deploying SQL Procedures, Functions, and Triggers
299(26)
Deploying on Linux, UNIX, and Windows
299(15)
Deploying SQL Procedures Using DDL
299(6)
Deploying Functions
305(3)
Deploying Triggers
308(1)
Deploying Using Get Routine and Put Routine
309(3)
Deploying Using Older Releases of DB2
312(1)
Code Page Considerations
313(1)
Backup and Recovery Considerations
313(1)
Deployment Considerations for DB2 for zSeries
314(2)
Deploying SQL Procedures
314(1)
Deploying Functions and Triggers
314(1)
Deployment Considerations Based on Your C Compiler Requirements
315(1)
Common Deployment Considerations for LUW and zSeries
316(3)
Deploying from One Database to Another
316(3)
Deploying in DB2 UDB for iSeries
319(5)
Using the Development Center
319(1)
Using iSeries Navigator and CL Commands in iSeries
319(5)
Summary
324(1)
Performance Tuning
325(30)
Performance Considerations for LUW
325(12)
The Configuration Advisor
325(3)
Monitoring SQL Performance
328(3)
Using Explain to Analyze Access Plans
331(2)
The Design Advisor
333(1)
Large Object (LOB) Considerations
334(1)
Temporary Tables Considerations
334(2)
Ongoing Maintenance to Keep Performance at Its Peak
336(1)
DB2 for iSeries Considerations
337(11)
Monitoring Memory Usage
338(1)
Performance Monitors and Commands
338(5)
Query Optimizer and Access Plans
343(3)
Variable Length Columns and Large Objects
346(1)
Database Statistics
347(1)
DB2 for zSeries Considerations
348(5)
The EDM Statement Cache
348(1)
The Performance Expert Tool
349(1)
Improving Response Time and Throughput
350(2)
Tuning Your Queries
352(1)
Limit Resources for a Stored Procedure
352(1)
Considerations for Stored Procedures in a Distributed Environment
353(1)
Summary
353(2)
Best Practices
355(16)
Table and Index Best Practices
356(2)
Table Considerations
356(1)
Temporary Table Considerations
356(1)
Index Considerations
357(1)
Best Practices for Easier Code Maintenance
358(2)
Code Readability
358(1)
Code Size
359(1)
Grouping SQL Procedures by Schema
359(1)
Naming Conventions
359(1)
Return Values Versus Out Parameters
359(1)
Exception Handling
359(1)
Commit and Rollback
360(1)
Best Practices for Performance
360(6)
Exceptions
360(1)
Repetitive SQL
360(1)
Table Truncation
360(1)
Reducing Locking
361(1)
Dynamic SQL for DDL
362(2)
Using a Single Insert to Replace Multiple Insert Statements
364(1)
Value Assignment
364(1)
Deterministic Versus Not Deterministic
364(1)
Case Statement
365(1)
Functions
365(1)
Working with Result Sets
366(1)
Cursor Considerations
366(1)
Limiting Result Sets
366(1)
Optimizing Result Set Returns
366(1)
Minimize Result Set Columns
367(1)
Precompile Options on iSeries
367(2)
Summary
369(2)
Appendix A Getting Started with DB2
371(40)
Getting Started with DB2 UDB for LUW
371(19)
Launching the DB2 Command Window
371(1)
Launching the DB2 Command Line Processor
372(2)
Overview of DB2 Architecture
374(1)
DB2 Instances
375(1)
Creating Databases
375(1)
Executing SQL in the DB2 Command Window
376(2)
Executing SQL in DB2 Interactive Mode
378(1)
Configuring the DB2 Environment
379(4)
Understanding Buffer Pools
383(1)
Working with Table Spaces
384(4)
Working with Tables
388(2)
Getting Started with DB2 UDB for iSeries
390(11)
Launching the Interface
391(1)
Overview of the DB2 UDB for iSeries Architecture
392(4)
Executing SQL in DB2 UDB for iSeries
396(2)
Working with Tables
398(1)
Catalog
399(2)
Getting Started with DB2 UDB for zSeries
401(8)
Overview of the BD2 UDB for zSeries Architecture
402(1)
Catalog
403(1)
Interacting with DB2 for zSeries
404(5)
Summary
409(2)
Appendix B Inline SQL PL for DB2 UDB for Linux, UNIX, and Windows
411(8)
Dynamic Compound Statement
411(4)
Stand-Alone Code
415(1)
Choosing Between Dynamic Compound Statements and SQL Procedures
416(1)
Summary
417(2)
Appendix C Building from the Command Line
419(12)
Configuring the Build Environment
419(2)
Building SQL Procedures
421(3)
Creating a DB2 Command-Line Processor Script
421(3)
Building SQL Procedures in DB2 UDB for iSeries
424(3)
Building SQL Procedures in DB2 for zSeries
427(2)
The Build Process
427(1)
Methods to Build a DB2 for zSeries SQL Procedure
428(1)
Summary
429(2)
Appendix D Using the DB2 Development Center
431(32)
Installing the DB2 Development Center
432(1)
DB2 for Windows
432(2)
DB2 for Linux and UNIX
434(1)
Using the Development Center for the First Time
435(6)
Development Center Views
441(1)
Customizing the Development Center
441(6)
Running Procedures
447(1)
Stored Procedure Run Settings
448(1)
Debugging Stored Procedures
449(3)
Debugging Nested Stored Procedures
452(2)
Working with Projects
454(1)
Importing Stored Procedures
455(2)
DB2 for iSeries Considerations
457(1)
DB2 for zSeries Considerations
457(1)
Environment Settings
458(1)
Developing SQL Stored Procedures from the Development Center
459(1)
The Project and Server Views
459(2)
Debugging DB2 for zSeries SQL Stored Procedures
461(1)
Summary
461(2)
Appendix E Security Considerations in SQL Procedures
463(10)
Privileges
463(4)
Privileges Required by Developers
464(2)
Privileges Required by Users
466(1)
Using Stored Procedures in a Production Environment
467(1)
DB2 for zSeries Considerations
468(1)
Dynamicrules Bind/Rebind Option Value
468(1)
The Package's Runtime Environment
468(1)
The Define Behavior
469(1)
The Invoke Behavior
469(1)
Common Attribute Values for the Define, and Invoke Behaviors
470(1)
Simplifying Authorization
470(1)
Summary
470(3)
Appendix F DDL
473(14)
Creating the Sample Database on LUW
473(1)
Creating the Sample Database on iSeries
474(1)
Creating the Sample Database on zSeries
475(1)
Sample Database DDL: Script 1 sampleDDL_1.db2
475(7)
DDL for Additional Database Objects: Script #2 sampleDDL_2.db2
482(5)
Appendix G Additional Resources
487(8)
IBM Redbooks
487(1)
LUW
487(1)
iSeries
488(1)
zSeries
488(1)
Cross-Platform
488(1)
Certification
488(1)
Certification Guides
489(1)
Tutorials
489(1)
Education
489(3)
IBM Learning Services
489(2)
IBM Solution Partnership Centers (SPCs)
491(1)
Tutorials
491(1)
Books
492(1)
Additional Websites
492(1)
DB2 FixPaks and Downloads
493(1)
Email Services and Periodicals
493(1)
User Groups and Conferences
494(1)
Appendix H Sample Application Code
495(26)
Receiving Result Sets in Java
495(9)
Receiving Result Sets in a Java Application
495(6)
Receiving Result Sets in a Java Stored Procedure
501(3)
Receiving Result Sets in a C or C++ Application
504(4)
Receiving Multiple Result Sets in Java
508(7)
Receiving Multiple Result Sets in a Java Application
508(3)
Receiving Multiple Result Sets in a Java Stored Procedure
511(4)
Receiving Multiple Result Sets in a C or C++ Application
515(6)
Index 521

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.