![](/img/trans.png)
[英]How to get output status of sqlplus command from shell/shell script?
[英]how to get SQL query output from sqlplus to bash script
如何使用 sqlplus 作为中间人执行 sql 查询或脚本并将 output 插入 bash 变量?
(至少)3 个好看的堆栈溢出和其他网站教程对我没有任何帮助,所以我发布了对我有用的内容,因为它可能对其他人有用。
编码:
#!/bin/bash
export ORACLE_SID=<DB_SID>
VAL=""
VAL=`sqlplus -s / as sysdba << EOF
whenever sqlerror exit sql.sqlcode;
set echo off
set heading off
@<sql_script_path>
exit;
EOF`
echo $VAL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.