# Impact of database downtime on the COBOL-DB2 program

DB2DatabaseBig Data Analytics

Problem: What will be the result if a COBOL-DB2 program tries to query a DB2 table, but the database in which table is residing is down?

## Solution

When we try to access any table using a COBOL-DB2 program and the DB2 database in which that table is residing is down then the COBOL-DB2 program will abend. In this case, the SQLCODE of SQLCA field will have the value as -904.

As per the IBM documentation SQLCODE -904 states.

“Unavailable resource. The database or tablespace is not available for use”

There are several methods which we can use in order to find the current status of the DB2 database.

Execute db2start command in the admin panel. If we get any message as given below, it indicates that DB2 is up.

11/14/2020 12:04:05 0 0 SQL1026N The database manager is already active.

Execute db2pd command in the admin panel. This command will give the current status of DB2 database. If the database is UP then it will give the number of days since the database instance is up and running.

-- Active -- 3 days 34:04:19 -- Date 2020-11-14-11.56.02.911862

In order to restart the DB2 database instance, we can use the following DBA command in the admin panel.

db2start


There may be a possibility that the database may be working as expected but there might be some issue at tablespace level. In such a scenario we can check the status of tablespace by executing the below command from the admin panel.

db2 “list tablespaces”
Published on 01-Dec-2020 04:40:02