Newsgroups: comp.databases.oracle.misc Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.glorb.com!sws1!ornl!news.er.usgs.gov!news From: Brian Peasland Subject: Re: Running SQLPlus from command line In-Reply-To: <1160589698.566021.186380@m73g2000cwd.googlegroups.com> X-Nntp-Posting-Host: edc-cv-160-65.cr.usgs.gov Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-ID: User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Sender: news@igsrsparc2.er.usgs.gov (Janet Walz (GD) x6739) Content-Transfer-Encoding: 7bit Organization: U.S. Geological Survey, Reston VA References: <1160578696.174696.66410@i3g2000cwc.googlegroups.com> <1160589698.566021.186380@m73g2000cwd.googlegroups.com> Mime-Version: 1.0 Date: Wed, 11 Oct 2006 18:11:26 GMT Lines: 75 Xref: dp-news.maxwell.syr.edu comp.databases.oracle.misc:130793 RLN wrote: > Thank you for the links to the syntax. > > Here are the 8 lines (simplified). > Right now, line 3 runs fine and connects. > Lines 4 thru 8 do not run at all unless I do these manually. I need > these to run as a batch process from start to finish. Lines 4 thru 8 > are outside of the SQL Plus environment in this batch process. How do > I 'include' lines 4 thru 8 so that they run in succession automatically > with no manual intervention? > > Startup and display SQL file that is running... > 1. @echo off > 2. echo Running TEST12.SQL > > connect to Oracle... > 3. SQLPLUS -s myUserID/myPass@myDBName > > Get the SQL file into the buffer... > 4. GET TEST12.SQL > > Run the SQL file.... > 5 . RUN > > Spool the output to .txt file... > 6. SPOOL TEST12.txt > > Turn off spooling... > 7. SPOOL OFF > > Exit SQL Plus.... > 8. EXIT > > What am I missing here? > Things look to be a mess.... For starters, you start spooling *after* you run the SQL script. How do you expect the output to show up? You need to turn on spooling, run your SQL statements, and then turn spooling off. Next, in Windows batch scripts, you won't be able to get interaction with SQL*Plus as you have done, which is why you have to do these manually. Instead, code your SQL script as follows: -- Start of TEST12.SQL script SPOOL c:\temp\test12.txt << Insert SQL statements here >> SPOOL OFF EXIT -- End of TEST12.SQL script Once all of the above is in your SQL script, envoke SQL*Plus as follows: SQLPLUS -s myUserID/myPass@myDBName @TEST12.sql HTH, Brian -- =================================================================== Brian Peasland dba@nospam.peasland.net http://www.peasland.net Remove the "nospam." from the email address to email me. "I can give it to you cheap, quick, and good. Now pick two out of the three" - Unknown