sqlplus:获取 file.sql 执行的参数

sqlplus: get parameters of file.sql execution

从一个 bat 文件我正在使用一个以相同方式调用 SQL/Plus 的进程:

@echo off
start sqlplus user/password@instance_name file.sql <instance_name>

echo End of process
pause

里面 file.sql 我有类似的东西 :

SET FEEDBACK OFF
SET UNDERLINE OFF
SET PAGESIZE 0
SET VERIFY OFF
SET SCAN ON
SET HEADING OFF
SET RECSEP OFF
SET TRIMSPOOL ON
SET FEEDBACK OFF
SET TERMOUT OFF
SET LINESIZE 1000
SET BLOCKTERMINATOR OFF

set instance_name=<FROM PARAMETER>

SET VERIFY ON
SET HEADING ON

EXIT

如何获取我在 SQL/Plus 中作为参数传递的名称?

使用&1


documentation 开始,SQL/Plus 命令的语法为:

SQLPLUS [ [Options] [Logon|/NOLOG] [Start] ]

然后 START parameter:

Start

@{url|file_name[.ext]} [arg ...]

Specifies the name of a script and arguments to run. The script can be called from the local file system or from a web server.

SQLPlus passes the arguments to the script as if executing the file using the SQLPlus START command. If no file suffix (file extension) is specified, the suffix defined by the SET SUFFIX command is used. The default suffix is .sql.

See the START command for more information.

然后对于 START 命令:

arg ...

Data items you wish to pass to parameters in the script. If you enter one or more arguments, SQL*Plus substitutes the values into the parameters (&1, &2, and so forth) in the script. The first argument replaces each occurrence of &1, the second replaces each occurrence of &2, and so on.