Re: Setting ORACLE_SID With ENV Variables

From: Chris Taylor <christopherdtaylor1994_at_gmail.com>
Date: Mon, 28 Jul 2014 09:26:38 -0500
Message-ID: <CAP79kiTSkkvu8RFFR-7hkp7oYQmeeAxz9=gtPMg7aRd7w_JrAQ_at_mail.gmail.com>



Add an echo $ORACLE_SID after you export it to verify it's setting correctly. Also you may want to export ORAENV_ASK=NO and then source oraenv to set the 'rest' of the Oracle environment variables. Also it is useful to set the LD_LIBRARY_PATH=$ORACLE_HOME/lib in some cases.

I tested this to verify it works:

#!/bin/bash

export SS_DB=TEST1
export ORACLE_SID=$SS_DB
export ORAENV_ASK=NO
export PATH=$PATH:/usr/local/bin
. /usr/local/bin/oraenv
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

echo ORACLE_SID=$ORACLE_SID
echo ORACLE_HOME=$ORACLE_HOME

sqlplus << EOF
/ as sysdba
set head on
set verify on
set feed on
set lines 1000
set trims on
select name from v\$database;
EOF OUTPUT:
ORACLE_SID=TEST1
ORACLE_HOME=/orabase/app/oracle/product/10.2.0

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jul 28 07:25:34 2014

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Enter user-name:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SQL> SQL> SQL> SQL> SQL>
NAME



PMKP 1 row selected.

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

On Mon, Jul 28, 2014 at 7:16 AM, Dave Morgan <oracle_at_1001111.com> wrote:

> Hello All,
> I am having a problem setting ORACLE_SID using env variables.
> For example, in a bash script:
>
> export SS_DB=ABCDB
> export TT_DB=DEFDB
>
> export ORACLE_SID=$SS_DB
>
> sqlplus fails with Oracle not available, no shared memory. However,
> echo $ORACLE_SID returns ABCDB.
>
> If I then set ORACLE_SID directly:
>
> export ORACLE_SID=ABCDB
>
> sqlplus works fine
>
> What am I missing?
>
> TIA
> Dave
>
> --
> Dave Morgan
> Senior Consultant, 1001111 Alberta Limited
> dave.morgan_at_1001111.com
> 403 399 2442
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jul 28 2014 - 16:26:38 CEST

Original text of this message