:
# 
# $Header: testdrive.sh,v 6.2 89/03/17 17:45:53 mho Exp $ testdrive.sh 
# 
#
# testdrive.sh
#
# usage: testdrive.sh <local_pass> <lhoststr> <remote_pass> <rhoststr>
#
#    This shell program calls sqlplus and contains a short .sql input
#        script to test the net drivers (Net*TCP, NET*Async, etc.)
#
#	<local_pass> - (e.g. scott/tiger)
#			user/password for connecting to local database
#	<lhoststr> - (e.g. T:hqsun6:UNIXDEV)
#			network driver specification string for local
#			database
#	<remote_pass> - (e.g. adams/wood)
#			user/password for connecting to remote database
#	<rhoststr> - (e.g. T:dread:N)
#			network driver specification string for local
#			database.
#
#    Testdrive.sh assumes itself to be called on the local machine (i.e.
#	the hostname specified in <lhoststr>).  It invokes sqlplus and 
#	connect, through <local_pass>, to the local database.  Then it
#	invokes the specifed network driver by
#		"connect <remote_pass>@<rhoststr>"
#	Upon connection, it performs some data definition and data
#	manipulation operations.  Finally, it calls the SQL*Plus
#	'COPY' command to copy a table back and forth between the
#	local and remote databases through the net driver.
#    It produces a spool file 'testdrive.out' in the current working
#	directory.

if test $# -ne 4
then echo "Usage: 
      testdrive.sh <local_pass> <lhoststr> <remote_pass> <rhoststr>"
     exit
fi

LOCAL_PASS="$1"
LHOSTSTR="$2"
REMOTE_PASS="$3"
RHOSTSTR="$4"

sqlplus ${LOCAL_PASS}@$LHOSTSTR >/dev/null 2>&1 <<!
spool testdrive.out
connect ${REMOTE_PASS}@$RHOSTSTR
create table temp (col1 number, col2 char(5));
insert into temp values (1,'A');
insert into temp values (2,'B');
insert into temp values (3,'C');
select * from temp;
update temp set col2 = 'BB' where col1 = 2;
select * from temp;
copy to ${LOCAL_PASS}@$LHOSTSTR -
replace tempcopy -
using select * from temp;
copy from ${LOCAL_PASS}@$LHOSTSTR -
create tempcopy2 -
using select * from tempcopy;
drop table temp;
select * from tempcopy2;
drop table tempcopy2;

connect ${LOCAL_PASS}@$LHOSTSTR
drop table tempcopy;

disconnect;
!
