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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In an application, multi-row inserts, positioned updates, and positioned deletes have the<br />

potential of expanding the unit of work, <strong>for</strong> instance by deleting a rowset. This can affect the<br />

concurrency of other users accessing the data. Minimize contention by adjusting the size of<br />

the host variable array, committing between inserts, updates, and preventing lock escalation.<br />

GET DIAGN<strong>OS</strong>TICS can be used in conjunction with and instead of the SQLCA to interrogate<br />

the results of all SQL statements. It is especially important when dealing with non-atomic<br />

multi-row insert statements, and objects with long names, which potentially no longer fit into<br />

the SQLCA message area. See <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 SQL Reference, SC18-7426-01<br />

<strong>for</strong> details.<br />

3.1.3 Multi-row fetch/update and multi-row fetch/delete in local applications<br />

When the cursor is positioned on a rowset, the rows belonging to the rowset can be updated<br />

or deleted:<br />

► Multi-row FETCH/UPDATE<br />

– Positioned UPDATE of multi-row FETCH<br />

– The rows of the current rowset are updated if the cursor is positioned on a rowset<br />

► Multi-row FETCH/DELETE<br />

– Positioned DELETE of multi-row FETCH<br />

– The rows of the current rowset are deleted if the cursor is positioned on a rowset<br />

If cursor CS1 is positioned on a rowset consisting of 10 rows of a table and we want to delete<br />

the fourth row of the rowset:<br />

EXEC SQL DELETE FROM T1 WHERE CURRENT OF CS1 FOR ROW 4 OF ROWSET;<br />

The same is applicable to UPDATE.<br />

Example of usage of multi-row fetch/update and fetch/delete in PL/I<br />

The example in Figure 3-3 shows the statements to update and delete rowsets of 10 rows<br />

from a table positioned by a rowset cursor.<br />

Chapter 3. SQL per<strong>for</strong>mance 33

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

Saved successfully!

Ooh no, something went wrong!