0

I have a test SQL script I'm trying to run in the PowerShell using SQLPlus. The path to the script looks like this:

@C:\&DI\test.sql

When I run this, I get the prompt

Enter value for di:

If I input &DI, everything works. I'd rather avoid any prompt. I've tried a bunch of different combinations of quotes, but haven't had any luck. Does anyone have any ideas?

Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
intern
  • 325
  • 1
  • 2
  • 12
  • 1
    Possible duplicate of [How to escape ampersands, semicolons, and curly braces in command-line powershell params?](https://stackoverflow.com/questions/36142786/how-to-escape-ampersands-semicolons-and-curly-braces-in-command-line-powershel) – mustaccio Nov 21 '18 at 19:21

1 Answers1

4

You're seeing a SQL*Plus prompt, not a PowerShell prompt.

SQL*Plus uses an ampersand to identify substitution variables by default. When it sees @C:\&DI it looks for a defined substitution variable called DI, and as it doesn't find one ir prompts you for it.

You can change the character it uses, or just disable that functionality, bu issuing:

set define off

before your @ run command.

SQL> @C:\&DI\test.sql
Enter value for di: xyz
SP2-0310: unable to open file "C:\xyz\test.sql"
SQL> set define off
SQL> @C:\&DI\test.sql
SP2-0310: unable to open file "C:\&DI\test.sql"
SQL>

Read more.

Alex Poole
  • 183,384
  • 11
  • 179
  • 318