Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Get value of a variable with sqlplus in bash script

sdfsdf sdfsdfsdfNov 16 2024

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

Comments
Post Details
Added on Nov 16 2024
2 comments
85 views