Using SQL Plus, you can run a script with the \"@\" operator from the command line, as in:
c:\\>sqlplus username/password@databasename @\
I'm able to run an SQL query by piping it to SQL*Plus:
@echo select count(*) from table; | sqlplus username/password@database
Give
@echo execute some_procedure | sqlplus username/password@databasename
a try.
Have you tried something like this?
sqlplus username/password@database < "EXECUTE some_proc /"
Seems like in UNIX you can do:
sqlplus username/password@database <<EOF
EXECUTE some_proc;
EXIT;
EOF
But I'm not sure what the windows equivalent of that would be.
For UNIX (AIX):
export ORACLE_HOME=/oracleClient/app/oracle/product/version
export DBUSER=fooUser
export DBPASSWD=fooPW
export DBNAME=fooSchema
echo "select * from someTable;" | $ORACLE_HOME/bin/sqlplus $DBUSER/$DBPASSWD@$DBNAME
sqlplus user/password@sid < sqlfile.sql
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:
<target name="executeSQLScript">
<exec executable="sqlplus" failonerror="true" errorproperty="exit.status">
<arg value="${dbUser}/${dbPass}@<DBHOST>:<DBPORT>/<SID>"/>
<arg value="@${basedir}/db/scripttoexecute.sql"/>
</exec>
</target>
@find /v "@" < %0 | sqlplus -s scott/tiger@orcl & goto :eof
select sysdate from dual;