Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

v$session interpreted as environmental variable in unix

Boopathy VasagamJan 20 2011 — edited Feb 10 2011
Hi All,
I want to execute a sql command from Unix shell script, which queries a table v$session. I am attaching the script below.

vi a2.sh
#!/bin/sh
echo "collect stat"
sqlplus -s usr_name/pwd@orcl<<EOF
select ss.username,se.SID,VALUE/100 cpu_usage_seconds from v$session ss,v$sesstat se,v$statname sn where se.STATISTIC# = sn.STATISTIC# and NAME like '%CPU used by this session%' and    se.SID = ss.SID and    ss.status='ACTIVE' and ss.username is not null order by VALUE desc;
EOF
My output is:

a2.sh
collect stat
select ss.username,se.SID,VALUE/100 cpu_usage_seconds from v ss,v se,v sn where se.STATISTIC# = sn.STATISTIC# and NAME like '%CPU used by this session%' and se.SID = ss.SID and    ss.status='ACTIVE' and ss.username is not null order by VALUE desc
                                                                     *
ERROR at line 1:
ORA-00942: table or view does not exist
Could anyone suggest me, is there any way by what way i can set any variables or any change oracle/unix environmental setup so that oracle can understand that this is a table name and not a environmental variable?

I have got the script running by having '\' as a escape character in front of the '$'. I wanted to know if there is any other way.
This post has been answered by MaximDemenko on Jan 20 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2011
Added on Jan 20 2011
7 comments
3,426 views