从启动批处理文件的PL / SQL脚本(带参数)

问题描述:

我在strugling从Windows传递参数给PL / SQL脚本.bat文件。

I'm strugling at passing arguments to a PL/SQL script from a Windows .bat file.

下面是批处理文件的内容:

Here is the content of the batch file :

@echo off
set mName = "test"
exit | sqlplus <connection_string> @test.sql %mName%
pause

这是TEST.SQL的内容:

And here is the content of test.sql :

set verify off
set serveroutput on size unlimited
BEGIN
  DBMS_OUTPUT.PUT_LINE('&&1');
END;
/

我希望看到测试出现在外壳,而是,我得到以下信息:

I would expect to see "test" appearing in the shell but instead, I get the following message :

Enter value for 1:
SP2-0546: User requested Interrupt or EOF detected.

有没有人有办法解决这个问题?

Does anyone have a solution to this problem ?

在你的 = 标志删除空格。这是我的工作批处理文件:

Remove the spaces around your = sign. Here's my working batch file:

@echo off
set mName="test"
exit | sqlplus <connection_string> @test.sql %mName%
pause

另外请注意,您可以使用sqlplus中的 -L 选项批处理作业:

-L 尝试登录只有一次,而不是对再次提示错误。

-L Attempts to log on just once, instead of reprompting on error.