Re: ORA-00942: table or view does not exist for v$session.

From: Tim X <timx_at_nospam.dev.null>
Date: Fri, 09 Jul 2010 08:37:02 +1000
Message-ID: <87aaq1wqgh.fsf_at_lion.rapttech.com.au>



trub3101 <trub3101_at_sky.com> writes:

> Hi all,
>
> Not as dramatic as the subject heading suggests fortunately!
>
> I have a function within a shell script 'kill_session' (below) which
> queries the v$session table. However, when I run the script I get this
> error message:
>
> Connected.
> select 'ALTER SYSTEM KILL SESSION '''||sid||','||serial#||''';' from v
> where schemaname = upper('film')
>
> *
> ERROR at line 1:
> ORA-00942: table or view does not exist
>
>
> function kill_session
> {
> /opt/ora/oracle/product/9.2.0/db_1/bin/sqlplus -s /nolog<<EOF
> _at_/home/oracle/system_conn.sql
> set head off
> set feed off
> set verify off
> set define off
> set scan off
> set serveroutput on
> spool ${WK_DIR}kill_${schema}_sessions.sql
> select 'ALTER SYSTEM KILL SESSION '''||sid||','||serial#||''';' from v
> $session where schemaname = upper('${schema}');
> spool off
> exit
> EOF
> }
>
> I would be ever so grateful if someone could help me out with this one
> please.
>
> Many thanks
> tb3101
>

My guess is that your shell is interpreting $ in v$session as a variable $session and expands it so that your table name ens up just being 'v'. Quote the $ and see if that fixes it.

Tim

-- 
tcross (at) rapttech dot com dot au
Received on Thu Jul 08 2010 - 17:37:02 CDT

Original text of this message