FAQs(331 to 345)

331) What are the four lockable units for DB2?

A) DB2 imposes locks of four differing sizes: pages, tables, tablespace and for indexes subpage.

332) What are the three lock types?

A) The three types are shared, update and exclusive. Shared locks allow two or more programs to read simultaneously but not change the locked space. An exclusive lock bars all other users from accessing the space. An update lock is less restrictive; it allows other transactions to read or acquire shared locks on the space.

333) What is isolation level?

A) SQL statements may return any number of rows, but most host languages deal with one row at a time by declaring a cursor that presents each row at a unique isolation level.

334) What is an intent lock?

A) An intent lock is at the table level for a segmented tablespace or at the tablespace level for a non-segmented tablespace. They indicate at the table or tablespace level the kinds of locks at lower levels.

335) What is the difference between static and dynamic SQL?

A) Static SQL is hard-coded in a program when the programmer knows the statements to be executed. For dynamic sql the program must dynamically allocate memory to receive the query results.

336) What is cursor stability?

A) Cursor stability means that DB2 takes a lock on the page the cursor is accessing and releases the lock when the cursor moves to another page.

337) What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?

A) The clause avoids closing the cursor and repositioning it to the last row processed when the cursor is reopened.

338) What is the SQL Communications Area and what are some of its key fields?

A) It is a data structure that must be included in any host-language program using SQL. It is used to pass feedback about the SQL operations to the program. Fields are return codes, error messages, handling codes and warnings.

339) What is the purpose of the WHENEVER statement?

A) The WHENEVER statement is coded once in the host program to control program actions depending on the SQL-CODE returned by each sql statement within the program.

340) What is the FREE command?

A) The FREE command can be used to delete plans and/or packages no longer needed.

341) DB2 can implement a join in three ways using a merge join, a nested join or a hybrid join. Explain the differences?

A) A merge join requires that the tables being joined be in a sequence; the rows are retrieved with a high cluster ratio index or are sorted by DB2. A nested join does not require a sequence and works best on joining a small number of rows. DB2 reads the outer table values and each time scans the inner table for matches. The hybrid join is a nested join that requires the outer table be in sequence.

342) Compare a subselect to a join?

A) Any subselect can be rewritten as a join, but not vice versa. Joins are usually more efficient as join rows can be returned immediately, subselects require a temporary work area for inner selects results while processing the outer select.

343) What is the difference between IN subselects and EXISTS subselect?

A) If there is an index on the attributes tested an IN is more efficient since DB2 uses the index for the IN. (IN for index is the mnemonic).

344) What is a Cartesian product?

A) A Cartesian product results from a faulty query. It is a row in the results for every combination in the join tables.

345) DB2 What is the difference between a package and a plan? How does one bind 2 versions of a CICS transaction with the same module name in two different CICS regions that share the same DB2 subsystem?

A) Package and plan are usually used synonymously, as in this site. Both contain optimized code for SQL statements - a package for a single program, module or subroutine contained in the database request module (DBRM) library. A plan may contain multiple packages and pointers to packages. The one CICS module would then exist in a package that could be referenced in two different plans.