阅读内容

Linux下用SHELL脚本执行带输入输出参数的ORACLE存储过程并得到结果

[日期:2008-05-18] 来源:Linux公社  作者:Linux整理


存储过程 myproc(in_num in number,out_num out number)

sql脚本模板mysql.sql
{
var nret number;
execute :nret := 0;--初始化

call myproc(in_code,:nret)--执行存储过程,in_code会被替换掉
/
select 'retcode[' || :nret || ']retcode' from dual--显示结果


/
quit;

}

SHELL脚本mysh.sh
{
#./mysh.sh 123
cd /home/myshell

sed "s/in_code/$1/" mysql.sql > mysql01.sql
#根据sql脚本模板生成实际脚本

sqlplus usr/pwd@db.my result$1.txt
#执行sql脚本并把结果输入result$1.txt

echo ok!

}

在Linux下执行./mysh.sh 123,生成result123.txt,myproc输出参数在'retcode['和']retcode'之间。 




相关资讯       Linux oracle 
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:

L
I
N
U
X


GOOGLE搜索
Google