Cover V03, I06
Article
Figure 1
Figure 2
Listing 1
Listing 2
Sidebar 1

nov94.tar


Listing 2: create.table.all

#!/bin/sh
#-----------------------------------------------------------------------------#
#- Author  of  this  Program:   William Genosa                               -#
#- Program Name and  Release:   @(#)create.table.all  1.1                    -#
#- File  Name  Used by  SCCS:   s.create.table.all                           -#
#- Tested on Sybase Versions:   4.2 and 4.92 for AIX                         -#
#- Last Date of Modification:   94/07/18                                     -#
#-                                                                           -#
#- Description:                                                              -#
#- This simple program is used to execute the create.table program for every -#
#- user table in the database assigned to the environment variable DATABASE. -#
#-----------------------Set The Environment Variables-------------------------#
CONFIG=/home/bill/.config        #- Global variable configuration file.      -#
if [ -f "${CONFIG}" ]            #- If  the  global  variable  configuration -#
then                             #- exists, then use it.    Otherwise set up -#
. ${CONFIG}                   #- the  variables  locally in this program. -#
else
SYBASE=/home/sybase           #- The sybase directory structure location. -#
DSQUERY=CLIENT                #- Locates the server in interface file.    -#
LOGIN=sa                      #- Sybase sa login.                         -#
PASSWORD=guessme              #- The password for sa.                     -#
SERVER=CLIENT                 #- The Sybase SQL Server to access.         -#
DATABASE=accounts             #- The database to access.                  -#
export SYBASE DSQUERY LOGIN PASSWORD SERVER DATABASE
fi

#-----------------------------------------------------------------------------#
#- The for loop below will execute the create.table program and generate the -#
#- sql which would re-create each user table in the database.                -#
#-----------------------------------------------------------------------------#
for table in `echo "set nocount on
go
select name
from ${DATABASE}..sysobjects
where type = 'U'
go" | ${SYBASE}/bin/isql -U${LOGIN} -P${PASSWORD} | \
grep -v "^ name                           $" | \
grep -v "^ ------------------------------ $" | \
grep -v "^$"`
do
/home/bill/create.table ${table}
done

#------------------------------------END--------------------------------------#