Here is part of our script we use to build a redirected restore.  Hopefully you can change it to work for you.
 

db2 "connect to ${dbnam}" > /dev/null 2>&1

#

# Now get the total number of tablespaces

#

db2 "list tablespaces" | grep "Tablespace ID" | tail -1 | awk '{print $4}' > jj7s23

totknt=`cat jj7s23`

#

# Now begin the cycle of collecting the information for

# each tablespace

#

knt=0

while (( ${knt} <= ${totknt} ))

do

db2 "list tablespace containers for ${knt} show detail" > tbs.reb

cat tbs.reb | grep "Name" | awk '{print $3}' > tbpth.reb

tbpth=""

for name in `cat tbpth.reb`

do

if [ -z "$tbpth" ]

then

tbpth=$name

fi

done

cat tbs.reb | grep "Total pages" | awk '{print $4}' > num.reb

integer i

integer tnum

tnum=0

for i in `cat num.reb`

do

tnum=$tnum+$i

done

cat tbs.reb | grep "Type" | awk '{print $3}' > fpchk.reb

for aa in `cat fpchk.reb`

do

tbs_control=$aa

done

if [ $tbs_control = "File" ]

then

print "set tablespace containers for ${knt} using (file '${tbpth}' ${tnum})" >>tbcont.reb

else

print "set tablespace containers for ${knt} using (path '${tbpth}')" >>tbcont.reb

fi

tbs_control=

knt=$(( $((knt)) + 1 ))

done

db2 terminate > /dev/null 2>&1

#

# Now cleanup all the temporary files

#

rm jj7s23

rm num.reb

rm tbpth.reb

rm tbs.reb

rm fpchk.reb

#

# This section will do the file editing to replace the directory structure

#

# ie. "(file '/db2tab/" will become "(file '/db2atab/"

#

#

TMPSED=/tmp/tempsed.$$

echo "s?$oldtab?$newtab?" > ${TMPSED}

echo "s?$oldind?$newind?" >> ${TMPSED}

echo "s?$oldcat?$newcat?" >> ${TMPSED}

-----Original Message-----
From: Ronald Draper [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 23, 2001 3:26 PM
To: [EMAIL PROTECTED]
Subject: Re: DB2EUG: create table

Hello everyone,

I'm trying to build a script to create the commands for a redirected restore and I need to know where in the catalog is the total pages value is stored or how it is calculated.  You can get the value when you run the "LIST TABLESPACE CONTAINER FOR tablespace id SHOW DETAIL," so it must be stored some where or calculated from stored data.  Any help would be great appreciated.

Thanks

Ron Draper
Computer Information Technology Specialist I
Missouri Department of Natural Resources
MIS Program
526-1077

[EMAIL PROTECTED]
Microsoft Certified Professional


Reply via email to