Application Development Guide


Common DB2 Application Techniques

  • Generated Columns
  • Identity Columns
  • Declared Temporary Tables
  • Controlling Transactions with Savepoints
  • Savepoint Restrictions
  • Savepoints and Data Definition Language (DDL)
  • Savepoints and Buffered Inserts
  • Using Savepoints with Cursor Blocking
  • Savepoints and XA Compliant Transaction Managers
  • DB2 enables you to use embedded SQL to handle common database application development problems.

    Generated columns
    Rather than using cumbersome insert and update triggers, DB2 enables you to include generated columns in your tables using the GENERATED ALWAYS AS clause. Generated columns provide automatically updated values derived from an SQL expression.

    Identity columns
    DB2 application developers often need to create a primary key for every row in a table. If you create a table that uses an identity column for the primary key, DB2 automatically inserts a unique value. When you use identity columns, your applications can benefit from increased performance due to a reduction in lock contention.

    Declared temporary tables
    Declared temporary tables are similar to regular tables, but persist only as long as the database connection and are not subject to locking or logging. If your application creates tables to process large amounts of data and drops those tables once the application has finished manipulating that data, consider using declared temporary tables. Declared temporary tables can increase the performance of your application and, for applications designed for concurrent users, simplify your application development effort.

    External savepoints
    While COMMIT and ROLLBACK statements enable you to control the behavior of an entire transaction, savepoints enable you to exercise more granular control within transactions. Savepoint blocks group several SQL statements together. If one of the sub-statements in the savepoint block results in an error, you can roll back just the failing sub-statement and complete the work of the other sub-statements.


    [ Top of Page | Previous Page | Next Page ]