IBM DB2 Computer Accessories User Manual


 
Chapter 5. Deploying pre-configured databases 227
The complete Windows example
Example 5-9 shows the full script used to create our ITSO sample database. All
DB2 commands are logged in the file createdb.log.
Example 5-9 The complete windows script for generating the database
@REM -------------------------------------------
@REM Step 1
@REM -------------------------------------------
setlocal
set DB2CLP=**$$**
@REM -------------------------------------------
@REM Step 2
@REM -------------------------------------------
call createdb.cmd
if errorlevel == 4 exit /b %errorlevel%
@REM -------------------------------------------
@REM Step 3
@REM -------------------------------------------
db2 -o- -l createdb.log -s CONNECT TO ITSODB
if errorlevel == 4 goto error
@REM -------------------------------------------
@REM Step 4
@REM -------------------------------------------
db2 -o- -l createdb.log -s -c- -tf itsodb.ddl
if errorlevel == 4 goto error
@REM -------------------------------------------
@REM Step 5
@REM -------------------------------------------
db2 -o- -l createdb.log commit
if errorlevel == 4 goto error
goto success
@REM -------------------------------------------
@REM Step 6a
@REM -------------------------------------------
:error
db2 -o- -l createdb.log rollback
db2 -o- -l createdb.log connect reset
exit /b 4
@REM -------------------------------------------
@REM Step 6b
@REM -------------------------------------------
:success