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.
Open a Command Prompt window, and type sqlcmd -SmyServer\instanceName. Replace myServer\instanceName with the name of the computer and the instance of SQL Server that you want to connect to. Press ENTER. The sqlcmd prompt (1>) indicates that you are connected to the specified instance of SQL Server.
SQL*Plus is a command-line tool that provides access to the Oracle RDBMS. SQL*Plus enables you to: Enter SQL*Plus commands to configure the SQL*Plus environment. Startup and shutdown an Oracle database. Connect to an Oracle database.
Oracle SQL Developer Command Line (SQLcl) is a free command line interface for Oracle Database. It allows you to interactively or batch execute SQL and PL/SQL.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With