Home » Infrastructure » Linux » get value of query sqlplus of bash script
get value of query sqlplus of bash script [message #690190] Sat, 16 November 2024 08:58 Go to next message
mmm286
Messages: 14
Registered: July 2014
Junior Member
Hi,

I'm trying to get only value variable of query in sqlplus in a shell script. I do:

data=`sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hosta)(Port=xxx))(CONNECT_DATA=(SID=sidddd)))"  <<EOF
set wrap off
set head off
set feed off
set pages 0
set linesize 32767
set feedback off
set pagesize 200
set echo off
alter session set nls_date_format='DD-MON-RR HH24:MI:SS';
select count(*) from table;
exit;
EOF`

but I get:

SQL*Plus: Release 18.0.0.0.0 - Production on Sat Nov 16 13:54:00 2024 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Last Successful login time: Sat Nov 16 2024 13:46:30 +01:00 Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.24.0.0.0 SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> 2758 SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.24.0.0.0


I only want to get: 2758

Any help please?

Thanks
Re: get value of query sqlplus of bash script [message #690191 is a reply to message #690190] Sat, 16 November 2024 10:10 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

sqlplus -s
Re: get value of query sqlplus of bash script [message #690192 is a reply to message #690191] Sun, 17 November 2024 10:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
    -S             Sets silent mode which suppresses the display of
                   the SQL*Plus banner, prompts, and echoing of
                   commands.
Re: get value of query sqlplus of bash script [message #690193 is a reply to message #690190] Mon, 18 November 2024 06:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Any feedback?

Re: get value of query sqlplus of bash script [message #690194 is a reply to message #690190] Tue, 19 November 2024 11:52 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
Any help please?

Any feedback please?
Previous Topic: Oracle Patch
Goto Forum:
  


Current Time: Sun Dec 22 04:38:22 CST 2024