# Function returns wrong values - solved

**URL:** <https://community.unix.com/t/function-returns-wrong-values-solved/260623>\
**Category:** Shell Programming and Scripting\
**Created:** [February 26, 2010, 8:56am UTC](https://community.unix.com/t/function-returns-wrong-values-solved/260623 "2010-02-26T08:56:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiamin](https://community.unix.com/letter_avatar/xiamin/32/5_5575768a8748004e209b776fc1b2916d.png) [@xiamin](https://community.unix.com/u/xiamin)\
**Post date:** [February 26, 2010, 8:56am UTC](https://community.unix.com/t/function-returns-wrong-values-solved/260623/1 "2010-02-26T08:56:13Z")

</div>

Hi

I have a small function which returns a wrong value.  
The function tries to make a connection to oracle database and tries to get the open\_mode of the database in the variable status.

However when a database is down the value of the status column is set to READWRITE i am not sure why.

I also unset the status variable still no luck

Any ideas ?

```nohighlight
get_db_status() {
unset status
echo "Entering DB STATUS scripts"
sid=$1
echo $sid
if ! check_sqlplus "$sid" ; then
  echo "Unable to use sqlplus for sid $sid"
  return 1
else
  echo "attempting to connect to database"
  echo $status
  echo $ORA_HOME
  echo "Status before entering sqlplus is $status"
  status=`sqlplus -silent "/ as sysdba" <<EOF
  conn /as sysdba
  set pagesize 0 feedback off verify off heading off echo off
  select replace(open_mode,' ','')
  from v\\$database;
  exit;
EOF`
echo "current status is $status"
fi

```

---------- Post updated at 02:56 PM ---------- Previous update was at 01:33 PM ----------

Hi

Apologies i found my faux pause  
Friday evening i had a brain fart

regards
