I believe the sqlplus
command doesn't accept a SQL statement (as a string) as a command-line parameter. You can run sqlplus
either interactively or in batch (giving a .sql
file as input).
However, you can do something like what you are asking, using operating system facilities. I don't know how this might work in Windows, but in Unix/Linux you can use a here document
. Something like this: (I masked my password and my machine name for privacy, but otherwise it's a screenshot showing the command and its output)
[oracle@******** ~]$ sqlplus mathguy/********@orclpdb <<EOF
> select empno, ename, sal
> from scott.emp
> where deptno = 30;
> EOF
SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 26 15:15:30 2021
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Last Successful login time: Fri Mar 26 2021 15:14:40 -07:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> 2 3
EMPNO ENAME SAL
---------- ---------- ----------
7499 ALLEN 1600
7521 WARD 1250
7654 MARTIN 1250
7698 BLAKE 2850
7844 TURNER 1500
7900 JAMES 950
6 rows selected.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0
- 64bit Production
[oracle@******** ~]$