两个步骤(正如您已经说过的):批处理脚本 + SQL 脚本。
批处理脚本
sqlplus scott/tiger@orcl @run_proc.sql
SQL 脚本 (run_proc.sql)
set serveroutput on
begin
p_test;
end;
/
exit
存储过程
create or replace procedure p_test is
begin
dbms_output.put_line('Hello!');
end;
/
在操作系统命令提示符处运行 runme.bat 会导致:
M:\>runme
M:\>sqlplus scott/tiger@orcl @run_proc.sql
SQL*Plus: Release 11.2.0.1.0 Production on Sri Lip 13 11:28:00 2018
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
hello
PL/SQL procedure successfully completed.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
M:\>
显然,它有效。现在,您可以使用不同的设置(回声、反馈等),但通常就是这样。