#!/bin/ksh
#
# Upshift all input to these variables
#
   typeset -u reply
   typeset -u reply_in
#
echo ""
echo "Welcome to the DISC demonstration of Omnidex working with Oracle."
echo "This script will create the orders demo database and build 6 tables"
echo "with approximately 1000 records."
echo ""
echo "The current Oracle environemt is set to:"
echo 'ORACLE_HOME='$ORACLE_HOME
echo 'ORACLE_SID='$ORACLE_SID
echo 'ORACLE_VERSION='$ORACLE_VERSION
echo ""
print -n "Are you ready to continue (Y/N) [Y]?"
read reply
reply_in=${reply:=Y}
if [[ "$reply_in" = "N" ]]; then
   exit
fi
orademo=$OMNIDEX_HOME/demo/oracle
oravrr=${ORACLE_VERSION%%.*}
case $oravrr in
8)
  cp $orademo/customers.ctl8 $orademo/customers.ctl
  cp $orademo/orders.ctl8 $orademo/orders.ctl
  cp $orademo/products.ctl8 $orademo/products.ctl
  cp $orademo/activity.ctl8 $orademo/activity.ctl
  cp $orademo/custnote.ctl8 $orademo/custnote.ctl
  cp $orademo/inventory.ctl8 $orademo/inventory.ctl
  sqlplus $1 @orders
  sqlload $1 customers
  sqlload $1 custnote
  sqlload $1 inventory
  sqlload $1 activity
  sqlload $1 products
  sqlload $1 orders
  ;;
7)
  cp $orademo/customers.ctl7 $orademo/customers.ctl
  cp $orademo/orders.ctl7 $orademo/orders.ctl
  cp $orademo/products.ctl7 $orademo/products.ctl
  cp $orademo/activity.ctl7 $orademo/activity.ctl
  cp $orademo/custnote.ctl7 $orademo/custnote.ctl
  cp $orademo/inventory.ctl7 $orademo/inventory.ctl
  sqlplus $1 @orders
  sqlload $1 customers
  sqlload $1 custnote
  sqlload $1 inventory
  sqlload $1 activity
  sqlload $1 products
  sqlload $1 orders;;
*)
  echo " "
  echo "Variable ORACLE_VERSION is undefined or invalid.  Please define " 
  echo "ORACLE_VERSION as the value '7' for Oracle 7 or '8' for Oracle 8 "
  echo "and try again."
  echo " "
  echo "Example:  export ORACLE_VERSION=8"
  echo " "
  ;;
esac
