SQL * plus does not tokenize its command line arguments when the program path contains spaces

I am using SQL * Plus with the following command line:

sqlplus user/ pw@TNS @test.sql foo 

The contents of test.sql should be:

 SET VERIFY ON DEFINE argone='&&1' SELECT '&argone' FROM dual; EXIT SQL.sqlcode 

Results:

  • When the SQL * Plus executable is located in C:\Program Files\Oracle Client\whatever\sqlplus.exe , then &&1 evaluates to Files\Oracle .
  • When the SQL * Plus executable is located in C:\Oracle\Client\10.2.xx\bin , then &&1 evaluates to foo .

Has anyone encountered this problem and had a way around it?

+6
source share
1 answer

You will need to use double quotation marks both on the command line and in the define expression to correctly hold arguments with spaces.

Script:

 SET VERIFY ON DEFINE argone="&&1" SELECT '&argone' FROM dual; EXIT SQL.sqlcode 

Command line:

 sqlplus user/ pw@TNS @test.sql "foo bar" 
+2
source

Source: https://habr.com/ru/post/897610/


All Articles