Using SQL Plus, you can run a script with the "@" operator from the command line, as in:
c:\>sqlplus username/password@databasename @"c:\my_script.sql"
But is it possible to just run a single command with a similar syntax, without a whole separate script file? As in:
c:\>sqlplus username/password@databasename @execute some_procedure
I am interested in this because I want to write a batch file that simply executes a command, without generating a bunch of two-line ".sql" files.
This will also work from the DOS command line. In this case the file sqlfile.sql contains the SQL you wish to execute.
This is how I solved the problem:
Have you tried something like this?
Seems like in UNIX you can do:
But I'm not sure what the windows equivalent of that would be.
For UNIX (AIX):
I'm able to run an SQL query by piping it to SQL*Plus:
Give
a try.