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.