Script to lookup a table id in a database and display it’s name.

Useful as sometimes just the table id is shown in the errlog.log or in IPM in the lock lists.

#!/bin/ksh
############################################################################
#
# PROGRAM NAME: table_id
# USAGE: table_id # SHORT DESC: Used for converting table id’s from the ingres error log
# to the actual table name in the database
#
############################################################################
# Assign input params
db=$1
relid=$2
relidx=$3
#
# Check all parameters are input
#
if [[ -z $db ]]
then
echo ‘Usage: table_id
exit
fi
if [[ -z $relid ]]
then
echo ‘Usage: table_id
exit
fi
if [[ -z $relidx ]]
then
echo ‘Usage: table_id
exit
fi
#
# Retrieve details from the database
#
sql $db << ! SELECT table_name, table_owner FROM iitables WHERE table_reltid = $relid AND table_reltidx = $relidx \p\g ! exit