Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Querying V$ views within scripts

Querying V$ views within scripts

From: stephen booth <stephenbooth.uk_at_gmail.com>
Date: Tue, 14 Dec 2004 12:25:52 +0000
Message-ID: <687bf9c4041214042560358c67@mail.gmail.com>


Recently I was asked to produce a couple of scripts that could be run from the UNIX prompt (or cron) to put all of the tablespaces in a database into backup mode then then put them back into non-backup mode (the plan being to run the first script to put them into backup mode, run the backup at filesystem level then run the second script to put them back). Below is my 'first stab':


#!/usr/bin/sh
ORACLE_SID=dctm
export ORACLE_SID
ORAENV_ASK=NO
export ORAENV_ASK
. oraenv
sqlplus /nolog <<EOF
connect / as sysdba
set echo off
set head off
set verify off
set feedback off
set pagesize 1024
alter system checkpoint;
spool alter_tbs_to_backup.sql
select 'alter tablespace '||tablespace_name||' begin backup;' from dba_tablespaces
where contents not in ('TEMPORARY')
/
spool off
@@alter_tbs_to_backup.sql
alter system archive log current;
EOF
exit


it seems to work fine and do what it's supposed to do. The problem is that if I try to query a v$view at anytime in the script (e.g. select * from v$backup; to confirm that the tablespaces are in backup mode) it reports that the view does not exist. If I run exactly the same commands interactively then the select from the v$ view works perfectly.

I've tried specifying, for example, sys.v$backup but still get the same error.

Presumably there's something blatantly obvious that I'm missing. Anyone come accross this or have any thoughts on what it might be?

I've tried a search of Metalink but nothing useful came up.

I'm using Oracle 9.2 on Solaris 9 (patched to 09/04).

Thanks

Stephen

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Dec 14 2004 - 06:21:12 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US