//Issue this statement to put the table in the right integrity mode SET INTEGRITY FOR itso.adefusr ALLOW NO ACCESS IMMEDIATE CHECKED

Regardless of these required adjustments, the output from db2look gives us an excellent starting point for the final set of DDL statements

5.2.2 Using a shell script

The DDL statements required to create the database layout and database objects are collected in one file. In our case, it is itso.ddl. You can run the DDL statements by simply invoking the command line processor (CLP) with the -foption as follows:

db2 -f itsodb.ddl

However, using a shell script to deploy the pre-configured database allows you to have the error handling logic in place. To control the behavior of the script, you can use the command line processor options and the return codes. Options chosen depend on the logic you want to implement.

Command line processor options

CLP comes with several options for you to control how CLP should behave. In this section, we only discuss the options that is relevant to error handling. For a complete reference of the available options, see DB2 Information Center at:

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admi

n.cmd.doc/doc/r0010410.html

To control the CLP in case of errors, we use these two options:

￿-s

This option controls whether the CLP will stop the execution or not if an error occurs. Default behavior is that the CLP does not stop. A minus sign (-)

immediately following an option letter turns the option off. To stop the execution when an error occurs, add the -s-option. For example:

db2 -s- -f itso.ddl

We recommend that you use this option if continue the DDL execution is pointless. For instance, if creating the database fail, there is no point to execute the rest of the DDL statements. On the other hand, it will not hurt to continue database object creation if the creation of views fails.

￿-c

This option control whether the CLP uses automatic commit or not. Default is on, which means that CLP will issue a commit after each statement. In other words it controls whether each statement is executed in its own unit of work,

222DB2 Deployment Guide

Page 236
Image 236
IBM manual Using a shell script, Command line processor options, 222 DB2 Deployment Guide