How do you create an Oracle SQLcl one-liner command

112 views Asked by At

I'm trying to run sqlcl on Windows 10 cmd with a one-liner query ...

Simply stated, here is what I'm trying to to do:

C:\ sql.exe -s username/[email protected]:1521/ORCL 'SELECT * FROM some_table'

I know this is possible in linux, but I'm getting

Bad Filename : 'SELECT

What I can do is put the query into a file called test.txt like this:

SELECT * FROM some_table;
quit;

and run the following command - this works (but I'm trying to avoid using the file as the source of the command):

C:\ sql.exe -s username/[email protected]:1521/ORCL @test.txt

Which produces the desired query results (in my case its this):

SOMETABLE

TEST1 TEST2 TEST3

I need to use this in a script to check the contents of a table after certain operations have been run on the system.

Since this question is specific to Windows, and sqlcl ... I'm going to leave it up with the answer ... the following works and the client automatically exits - (no need to quit):

C:\ echo SELECT * FROM some_table | sql.exe -s username/[email protected]/1521/ORCL
0

There are 0 answers