#! /usr/bin/ksh

# @version $Id: createTemplateBuilder.ksh,v 1.6 2009/11/10 21:36:20 dweiner Exp $

#---------------------------------------------------------------------
# MAIN  --------------------------------------------------------------
#---------------------------------------------------------------------

typeset database_name

clear
if test -z "$1"
then
	print ""
	print "\t Tandberg Television WatchPoint Template Builder Schema Creation Wizard"
	print "\t=======================================================\n"
	read database_name?"	What is the name of the existing WatchPoint database where you would like to install the Template Builder schema? The default is [ttv] "
else
	database_name="$1"
fi

if [[ -z $database_name ]]
then
  database_name=ttv
fi

export ORACLE_SID=${database_name}

sqlplus -s /nolog << EOF
   connect / as sysdba
   PROMPT creating the Template Builder Schema in the ${ORACLE_SID} database PLEASE WAIT
   spool createTemplateBuilder.log
   PROMPT ...Creating the TemplateBuilderDB package
   @TemplateBuilderDB.pks
   PROMPT ...Executing the TemplateBuilderDB package
   exec sys.TemplateBuilderDB.install_templateBuilder;
   PROMPT
   PROMPT Installation complete.  The results are listed below. 
   select * From install_table;
   select setting_value as "Template Builder Version"
   from WPTB.system_settings 
   where setting_type = 'RELEASE';
   PROMPT
   PROMPT An editional log file is located in createTemplateBuilder.log
   spool off
   exit;
EOF

exit 0
