batch-file - 使用批处理文件在 Oracle 数据库中执行 SQL 过程
问题描述
我创建了一个 .bat 文件来执行这些行的过程:
echo off
sqlplus username/password@databasename
set heading off
set feedback off
BEGIN
AML.DO_ACCOUNT_AML() ;
COMMIT
END;
/
exit;
!
. 它只能连接到数据库,但不能执行查询。
解决方案
两个步骤(正如您已经被告知的那样):批处理脚本 + 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:\>
显然,它有效。现在,您可以使用不同的设置(回声、反馈等),但是 - 通常,就是这样。
推荐阅读
- python - python 上的 Azure Edge 解决方案无法创建多个设备孪生?
- vtk - 在 Python 中使用 paraview 过滤器,Paraview python api
- java - 究竟是什么导致网格不显示?爪哇摇摆
- database - 如何查找每个 Hsql 数据库表的磁盘使用情况(使用 SQL、DataGrip 或其他解决方案)?
- sql-server - SQL Server 中的大型 USERSTORE_OBJPERM
- linux - 如果通过 cron 执行 perl 系统功能不起作用
- magento - 本地 Windows 机器上的 PWA 设置
- qt - Linux下无法使用QML QtGamepad
- python - selenium 中 webdriver 的调用选项
- sockets - 为什么 systemd 总是重启 udp 服务?