为了能够使用默认值,您可以执行以下操作:
在你的主文件中:
SET VERIFY OFF
-- specify as many substitution variable as you need to.
COLUMN 1 NEW_VALUE 1 noprint
COLUMN 2 NEW_VALUE 2 noprint
REM COLUMN 3 NEW_VALUE 3 noprint
REM ..........
REM COLUMN <N> NEW_VALUE <N> noprint
SELECT '' "1"
, '' "2"
FROM dual
WHERE 0 = 1;
-- Default values.
select decode('&1', null, 'Default1', '&1') "1"
, decode('&2', null, 'Default1', '&2') "2"
from dual;
-- prints substitution variables' values
@@set_target_schema.sql '&1' '&2'
undefine 1
undefine 2
结果:
-- without parameters
SQL> @c:\main.sql
'DEFAULT 'DEFAULT
-------- --------
Default1 Default1
-- with parameters
SQL> @c:\main.sql parameter1 parameter2
'PARAMETER 'PARAMETER
---------- ----------
parameter1 parameter2