Home >Database >Mysql Tutorial >ETL调度开发(5)连接数据库执行数据库命令子程序

ETL调度开发(5)连接数据库执行数据库命令子程序

WBOY
WBOYOriginal
2016-06-07 16:00:011231browse

ETL调度中读写数据信息,都需要连接数据库,下面的子程序通过传入的数据库连接字符串和数据库命令(或SQL)执行所需要的操作: #!/usr/bin/bash#created by lubinsu#2014source ~/.bash_profilevalues=`sqlplus -S $1 EOF set heading off feedback off page

ETL调度中读写数据信息,都需要连接数据库,下面的子程序通过传入的数据库连接字符串和数据库命令(或SQL)执行所需要的操作:

#!/usr/bin/bash
#created by lubinsu
#2014
source ~/.bash_profile
values=`sqlplus -S $1 << EOF
  set heading off feedback off pagesize 0 verify off echo off
    WHENEVER SQLERROR exit SQL.SQLCODE ROLLBACK 
    $2
    commit;
    exit 
EOF`
echo "${values}"
参数的参数依次是:数据库连接字符串,数据库命令(或SQL语句)
Statement:
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