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

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

WBOY
Release: 2016-06-07 16:51:37
Original
3209 people have browsed it

存储过程 myproc(in_num in number,out_num out number)sql脚本模板mysql.sql{var nret number;execute :nret := 0;--初始化call

存储过程 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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template