Getting sqlresult into bash variable without oracle header/footer

非 Y 不嫁゛ 提交于 2019-12-25 06:20:58

问题


#!/bin/bash -x

x=`sqlplus scott/tiger@xe<<endl
set heading off
select sysdate from dual;
exit
endl`

echo the answer is $x

is outputting

the answer is SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 27 09:01:25 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> SQL> 27-MAR-13 SQL> Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Productiong 

All I want is the result of the query sysdate. How do I get rid of all the oracle relase, copyright, ... info.


回答1:


I found the answer

sqlplus -s

will then eliminate the headers



来源:https://stackoverflow.com/questions/15663763/getting-sqlresult-into-bash-variable-without-oracle-header-footer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!