首页 / 数据库 / MySQL / 用脚本调用Oracle存储过程
先准备好一个sql脚本demo.sqlset serveroutput on
declare
v_name dept.dname%type;
begin
select dname into v_name from dept where deptno=&1;
dbms_output.put_line("department name is: "||v_name);
end;
/
exit;然后在终端下执行:sqlplus "scott/tiger@orcl" @demo.sql 20返回:SQL*Plus: Release 9.2.0.4.0 - Production on Thu Oct 17 21:37:28 2013
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Productionold 4: select dname into v_name from dept where deptno=&1;
new 4: select dname into v_name from dept where deptno=20;
department name is: RESEARCH
PL/SQL procedure successfully completed.
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production注意:我们可以给脚本传参数,在脚本中用&1,&2这样的参数更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址