How can I issue a single command from the command line through sql plus?

command-line, oracle, sqlplus

Solution

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.

Problem

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.

Original source