How to use V$tables in UNIX shell script?

Hi All,

In my script I have used the below code to retrieve the instance name

V_INSTANCE_NAME=`sqlplus -s ${APPS_USR_PSWD} <<+
                    set pagesize 0 linesize 256 feedback off verify off head off echo off
                    set serveroutput off
                    select UPPER(instance_name) FROM V$INSTANCE;
exit;
+`

I have got the following error

ORA-00942: table or view does not exist

and i have tried with

select UPPER(instance_name) FROM V\$INSTANCE;

escape character,but nothing is retrieved.

Please advice me how to resolve this.

Thanks in advance.

Regards,
P.Kalidoss

I think that table will not be accessible for your DB user.

If you are interested in getting the DB instance an alternate approach would be:

select ora_database_name from dual;
1 Like

try this

CATALOG_INSTANCE="V\$INSTANCE"

V_INSTANCE_NAME=`sqlplus -s ${APPS_USR_PSWD} << 
                    set pagesize 0 linesize 256 feedback off verify off head off echo off
                    set serveroutput off
                    select UPPER(instance_name) FROM ${CATALOG_INSTANCE};
exit;
`