用脚本调用Oracle存储过程

WBOY
發布: 2016-06-07 16:48:26
原創
1244 人瀏覽過

先准备好一个sql脚本demo.sql set serveroutput ondeclarev_name dept.dname%type;beginselect dname into v_name from dept whe

先准备好一个sql脚本demo.sql

set 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 - Production

old 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这样的参数

本文永久更新链接地址:

linux

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!