#!/bin/sh
#*******************************************************************************
#             PACOR II SOFTWARE
#       Property of the U.S. Government
#            NASA/GSFC/Code 560
#*******************************************************************************
#PURPOSE: Creates the QAWS table(s) referential integrity constraints. 
#
#INVOCATION METHOD: ins_referential_QAWS user/pw  log_file [A | D]
#
#
#DEVELOPMENT HISTORY:
#
#	Author		Change-ID   Release	Date	Description of Change
#	------		---------   -------	----	---------------------
#    I. Horowitz        ACE0615     ACE R2.0  06/28/96  Added QAWS ref. constraints
#							 to DPS DB
#
#
#NOTES: This script should be run after TableBuilder is run. 
#*********************************************************************************
clear

if [ $# -ne 3 ]
then
   echo '************************************************************'
   echo 'Error, you must enter an Oracle UserID/Password, Log file,  '
   echo 'and the add (A) or drop (D) option                          '
   echo '************************************************************'
   exit
fi

echo ''

if [ "$3" = D -o "$3" = d ]
then
 echo '**********************************************'
 echo 'Dropping QAWS tables referential integrity ...'
 echo '**********************************************'
 sqlplus $1 << ENDORACLE >> $2
   ALTER TABLE db_QEventlog
	    DROP CONSTRAINT fk_QEventlogMessID;
exit;
ENDORACLE

elif [ "$3" = A -o "$3" = a ]
then
   echo '********************************************'
   echo 'Adding QAWS tables referential integrity ...'
   echo '********************************************'
   sqlplus $1 << ENDORACLE >> $2
   ALTER TABLE db_QEventlog
	    ADD CONSTRAINT fk_QEventlogMessID FOREIGN KEY
		(MessageID) references db_QMessage(MessageID);;
   exit;
ENDORACLE

else
 exit
fi
