Home » Infrastructure » Linux » Connect to SQLPlus from Shell script (Oracle 10g)
Connect to SQLPlus from Shell script [message #347025] Wed, 10 September 2008 08:03 Go to next message
gokul_ifs
Messages: 41
Registered: March 2006
Location: india
Member
Hi All,

My requirement is to connect to sqlplus from a linux sell script and execute some SQL queries.

Please share if you have some sample codes for this.

Thanks,
GOKUL
Re: Connect to SQLPlus from Shell script [message #347032 is a reply to message #347025] Wed, 10 September 2008 08:28 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW the Posting Guidelines as stated in URL above

I am sorry to see that GOOGLE & SEARCH function on this forum are both broken for you

Repairs have been started so please wait patiently until completed.
Additional information will be present after the Internet starts working for you once again.

[Updated on: Wed, 10 September 2008 08:29] by Moderator

Report message to a moderator

Re: Connect to SQLPlus from Shell script [message #347039 is a reply to message #347025] Wed, 10 September 2008 08:39 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Please share if you have some sample codes for this.

Laughing
Already shared, you just don't read them.

Regards
Michel
Re: Connect to SQLPlus from Shell script [message #358303 is a reply to message #347025] Mon, 10 November 2008 11:14 Go to previous messageGo to next message
OracleDBA1
Messages: 7
Registered: November 2008
Junior Member
hi,

You can easily connect the SQL prompt using the following code:

#/bin/sh
--- some export commands to set the ORACLE_HOME, ORACLE_SID, TNS_ADMIN etc., -------
............
............

VALUE=`sqlplus -s scott/tiger@database_name<<END
spool on
-- or you can also set spool to a location by spool abx.txt
set feedback off
set echo off
set termout off
set trimspool on
select name from v$database;
....
....
....
your SQL code
...
...
end
spool off
END`
(P.S. note the ` char there.)

Save your file as .sh

chmod 777 filname.sh

execute your script.

[Updated on: Mon, 10 November 2008 11:15]

Report message to a moderator

Re: Connect to SQLPlus from Shell script [message #358309 is a reply to message #358303] Mon, 10 November 2008 11:26 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Code is much easier to read if you format it and use code tags.
Read OraFAQ Forum Guide, especially "How to format your post?" section.

Regards
Michel
Previous Topic: setting up NLS CHARACTER SET
Next Topic: Display VAriable problem on SLES9
Goto Forum:
  


Current Time: Fri Mar 29 07:18:48 CDT 2024