Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Running SQLPlus from command line
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_at_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:
Once all of the above is in your SQL script, envoke SQL*Plus as follows:
SQLPLUS -s myUserID/myPass_at_myDBName @TEST12.sql
HTH,
Brian
-- =================================================================== Brian Peasland dba_at_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" - UnknownReceived on Wed Oct 11 2006 - 13:11:26 CDT
![]() |
![]() |