19.06.2013 Views

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

FETCH<br />

FROM<br />

Figure 3-45 FETCH syntax<br />

INSENSITIVE<br />

SENSITIVE<br />

single-fetch-clause: ,<br />

These are implications on the FETCH statement using dynamic scrollable cursors:<br />

► The keyword INSENSITIVE is not allowed (SQLCODE -244) in the FETCH statement:<br />

– If the associated DECLARE CURSOR statement is specified as SENSITIVE DYNAMIC<br />

SCROLL, or<br />

– If the associated DECLARE CURSOR statement is specified as ASENSITIVE<br />

SCROLL, and <strong>DB2</strong> selects SENSITIVE DYNAMIC SCROLL <strong>for</strong> the associated<br />

SELECT statement.<br />

► SQLCODE +231 is returned in special cases<br />

– If FETCH CURRENT or FETCH RELATIVE +0 are requested, but the row on which the<br />

cursor is positioned has been deleted or updated so that it no longer meets the criteria.<br />

It happens only when using ISOLATION(CS) and CURRENT DATA(NO), which allows<br />

the row retrieved without taking locks.<br />

Data concurrency in dynamic scrollable cursors<br />

The characteristic of using dynamic scrollable cursors is that you can see immediately the<br />

newly updated or inserted or deleted data of your application. To get maximum data<br />

concurrency and get a high per<strong>for</strong>mance, you should use CURRENTDATA(NO) as a bind<br />

option and ISOLATION(CS) as an ISOLATION level.<br />

CURRENTDATA is a bind option which helps to determine the currency of data returned by<br />

an application cursor. In a local environment, CURRENTDATA can only have an impact <strong>for</strong> an<br />

application bound with ISOLATION(CS) and executing read-only queries which do not utilize<br />

a work file. The primary benefit in using CURRENTDATA(NO) is per<strong>for</strong>mance. This is<br />

especially true in a data sharing environment; using CURRENTDATA(NO) should reduce lock<br />

contention and CPU utilization.<br />

96 <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 Per<strong>for</strong>mance <strong>Topics</strong><br />

FETCH syntax<br />

cursor-name<br />

INTO host-variable<br />

INTO DESCRIPTOR<br />

NEXT<br />

PRIOR<br />

FIRST<br />

LAST<br />

CURRENT<br />

BEFORE<br />

AFTER<br />

ABSOLUTE host-variable<br />

integer-constant<br />

RELATIVE host-variable<br />

integer-constant<br />

descriptor-name<br />

single-fetch-clause<br />

No new syntax.<br />

Cannot specify<br />

INSENSITIVE -<br />

SQLCODE -244

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

Saved successfully!

Ooh no, something went wrong!