10.12.2012 Views

Application Programming and SQL Guide - Kmlinux

Application Programming and SQL Guide - Kmlinux

Application Programming and SQL Guide - Kmlinux

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

#<br />

|<br />

|<br />

|<br />

Flexibility of dynamic <strong>SQL</strong> . . . . . . . . . . . . . . . . . . . 544<br />

Limitations of dynamic <strong>SQL</strong> . . . . . . . . . . . . . . . . . . . 544<br />

Dynamic <strong>SQL</strong> processing . . . . . . . . . . . . . . . . . . . 544<br />

Performance of static <strong>and</strong> dynamic <strong>SQL</strong> . . . . . . . . . . . . . . 545<br />

Caching dynamic <strong>SQL</strong> statements . . . . . . . . . . . . . . . . . 546<br />

Using the dynamic statement cache . . . . . . . . . . . . . . . . 547<br />

Using the statement cache table . . . . . . . . . . . . . . . . . 549<br />

Keeping prepared statements after commit points . . . . . . . . . . 549<br />

Limiting dynamic <strong>SQL</strong> with the resource limit facility . . . . . . . . . . . 551<br />

Writing an application to h<strong>and</strong>le reactive governing . . . . . . . . . . 552<br />

Writing an application to h<strong>and</strong>le predictive governing . . . . . . . . . 552<br />

Using predictive governing <strong>and</strong> down-level DRDA requesters . . . . . . 552<br />

Using predictive governing <strong>and</strong> enabled requesters . . . . . . . . . . 553<br />

Choosing a host language for dynamic <strong>SQL</strong> applications . . . . . . . . . 553<br />

Dynamic <strong>SQL</strong> for non-SELECT statements . . . . . . . . . . . . . . 553<br />

Dynamic execution using EXECUTE IMMEDIATE . . . . . . . . . . . 554<br />

Dynamic execution using PREPARE <strong>and</strong> EXECUTE . . . . . . . . . 555<br />

Dynamic execution of a multiple-row INSERT statement . . . . . . . . 557<br />

Using DESCRIBE INPUT to put parameter information in an <strong>SQL</strong>DA . . . 559<br />

Dynamic <strong>SQL</strong> for fixed-list SELECT statements . . . . . . . . . . . . 560<br />

Declaring a cursor for the statement name . . . . . . . . . . . . . 561<br />

Preparing the statement . . . . . . . . . . . . . . . . . . . . 561<br />

Opening the cursor . . . . . . . . . . . . . . . . . . . . . . 562<br />

Fetching rows from the result table . . . . . . . . . . . . . . . . 562<br />

Closing the cursor . . . . . . . . . . . . . . . . . . . . . . 562<br />

Dynamic <strong>SQL</strong> for varying-list SELECT statements . . . . . . . . . . . 562<br />

What your application program must do . . . . . . . . . . . . . . 562<br />

Preparing a varying-list SELECT statement . . . . . . . . . . . . . 563<br />

Executing a varying-list SELECT statement dynamically . . . . . . . . 572<br />

Executing arbitrary statements with parameter markers . . . . . . . . 573<br />

How bind options REOPT(ALWAYS) <strong>and</strong> REOPT(ONCE) affect dynamic<br />

<strong>SQL</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . 575<br />

Using dynamic <strong>SQL</strong> in COBOL . . . . . . . . . . . . . . . . . . 576<br />

Chapter 25. Using stored procedures for client/server processing . . . . 577<br />

Introduction to stored procedures . . . . . . . . . . . . . . . . . . 577<br />

An example of a simple stored procedure . . . . . . . . . . . . . . 578<br />

Setting up the stored procedures environment . . . . . . . . . . . . . 582<br />

Defining your stored procedure to DB2 . . . . . . . . . . . . . . 583<br />

Refreshing the stored procedures environment (for system administrators) 587<br />

Moving stored procedures to a WLM-established environment (for system<br />

administrators) . . . . . . . . . . . . . . . . . . . . . . . 588<br />

Writing <strong>and</strong> preparing an external stored procedure . . . . . . . . . . . 589<br />

Language requirements for the stored procedure <strong>and</strong> its caller . . . . . . 590<br />

Calling other programs . . . . . . . . . . . . . . . . . . . . 590<br />

Using reentrant code . . . . . . . . . . . . . . . . . . . . . 590<br />

Writing a stored procedure as a main program or subprogram . . . . . . 591<br />

Restrictions on a stored procedure . . . . . . . . . . . . . . . . 594<br />

Using COMMIT <strong>and</strong> ROLLBACK statements in a stored procedure . . . . 594<br />

Using special registers in a stored procedure . . . . . . . . . . . . 595<br />

Accessing other sites in a stored procedure . . . . . . . . . . . . . 597<br />

Writing a stored procedure to access IMS databases . . . . . . . . . 598<br />

Writing a stored procedure to return result sets to a DRDA client . . . . . 598<br />

Preparing a stored procedure . . . . . . . . . . . . . . . . . . 600<br />

Binding the stored procedure . . . . . . . . . . . . . . . . . . 601<br />

Writing a REXX stored procedure . . . . . . . . . . . . . . . . 602<br />

Contents xi

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!