[英]how to get SQL query output from sqlplus to bash script
how to execute sql query or script using sqlplus as the middle man and insert output to bash variable?如何使用 sqlplus 作为中间人执行 sql 查询或脚本并将 output 插入 bash 变量?
nothing worked for me of the (at least) 3 good looking stack-overflow and other websites tutorials so I'm posting what worked for me, for the of chance that it will be useful to some one else. (至少)3 个好看的堆栈溢出和其他网站教程对我没有任何帮助,所以我发布了对我有用的内容,因为它可能对其他人有用。
the code:编码:
#!/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.