Home » Infrastructure » Unix » How to call an sql script from Shell script
How to call an sql script from Shell script [message #228488] Tue, 03 April 2007 03:47 Go to next message
lokeshg82
Messages: 23
Registered: February 2007
Location: chennai
Junior Member
dear Experts,

i want to call an sql script from shell script..

pls suggest me.
Re: How to call an sql script from Shell script [message #228491 is a reply to message #228488] Tue, 03 April 2007 03:55 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

Hi,
i want to call an sql script from shell script..
Can you please give us more details about your requirements.


regards
Taj
Re: How to call an sql script from Shell script [message #228507 is a reply to message #228491] Tue, 03 April 2007 04:32 Go to previous messageGo to next message
lokeshg82
Messages: 23
Registered: February 2007
Location: chennai
Junior Member
hi,

see my below code,

vi Accid_Handle.ksh
echo `date` : Begin Process Accid Handle[ Accid_Handle.ksh ]
echo '################################################################ '
echo ' Enter the WTN'
read data
echo '################################################################ '
export ORACLE_USER=Swb
export ORACLE_PASSWORD=swbt3st
export DB_NAME=yteprod
export LOG_DIR=/var/log/pbiace
export PATH=/usr/local/pbiace/current/bin

export CONNSTRING=${ORACLE_USER}/${ORACLE_PASSWORD}@${DB_NAME}

if [ ! $ORACLE_USER ] ; then
echo `date` : ERROR: ORACLE_USER environment variable WAS NOT established
echo `date` : -------------------------------- END $filename ---------------------------------------
exit 2
fi

if [ ! $ORACLE_PASSWORD ] ; then
echo `date` : ERROR: ORACLE_PASSWORD environment variable WAS NOT established
echo `date` : -------------------------------- END $filename ---------------------------------------
exit 3
fi

if [ ! $DB_NAME ] ; then
echo `date` : ERROR: DB_NAME environment variable WAS NOT established
echo `date` : -------------------------------- END $filename ---------------------------------------
exit 4
fi

if [ ! $ORACLE_HOME ] ; then
echo `date` : ERROR: ORACLE_HOME environment variable WAS NOT established
echo `date` : -------------------------------- END $filename ---------------------------------------
exit 5
fi


$ORACLE_HOME/bin/sqlplus -s $CONNSTRING @myscript.sql $data <<-EOF
exit
EOF


here,inside the code i want to call handle.sql script which is called as @handle.

pls guide me.....
Re: How to call an sql script from Shell script [message #228523 is a reply to message #228507] Tue, 03 April 2007 05:06 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

I hope you are joking...

http://www.orafaq.com/forum/t/77309/91729/

After ALOTof help you made it work.
But obviously you dont understand what you did, since
the question you are asking has already been answered in your previous post.


I think you really would benifit from attending a unix "basic" class.
Re: How to call an sql script from Shell script [message #228543 is a reply to message #228523] Tue, 03 April 2007 06:00 Go to previous messageGo to next message
lokeshg82
Messages: 23
Registered: February 2007
Location: chennai
Junior Member
actually my question is here i already called one sql script.
there is any possibility to call another sql script in the same shell script,if yes can i use the same syntax format for that also??

i agreed that i have not much knowledge about unix,thats y me asking these kind of witty doubt..otherwise i won't...
Re: How to call an sql script from Shell script [message #229193 is a reply to message #228488] Thu, 05 April 2007 17:18 Go to previous message
nmacdannald
Messages: 460
Registered: July 2005
Location: Stockton, California - US...
Senior Member
#!/bin/ksh
#@(#)hotbackup_cancel -- takes all S2000 tablespaces out of backup mode
###
# Korn script to cancel hot backup of the S2000 database
#
###
#
#
# Inform operator what job they have requested
# Ask if they wish to continue
#
echo " "
echo "*****"
echo Canceling hot backup, taking all tablespaces out of backup mode
echo "Continue? (Y/N)"
read answer
if [[ "$answer" = [Yy]* ]]
then
pwddir=`pwd`
echo Enter password for S2000 ORADB
sttyops=`stty -g`
stty -echo
echo "Password: "\\c
read password
echo " "
stty $sttyops
#
# Start the hot backup cancel
#
sqlplus ORADBA/$password << EOF
@$pwddir/hotbackup_cancel
exit
EOF
fi
Previous Topic: Ho to send attachement in read only mode through Unix mailx command(**Urgent***)
Next Topic: How to get a chunk of a file?
Goto Forum:
  


Current Time: Sun Nov 24 23:44:42 CST 2024