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!

Generate Statspack report automatically once per day

lesakAug 3 2011 — edited Oct 4 2011
Hi,

I'd like to generate statspack report once per day and send automatically to my emial important parts of this report. Right now I have such sript:
su - oracle -c "sqlplus perfstat/perfstat" << EOF
column esnap new_value end_snap noprint
select max(snap_id) as esnap from stats$snapshot;
column bsnap new_value begin_snap noprint
select max(snap_id)-24 as bsnap from stats$snapshot;
define report_name=/home/oracle/sp_proba.lst
@?/rdbms/admin/spreport
EOF
Of course I delete lines below which parse and send information to my email. Important for me is that those command works when I paste it line by line to perfstat session (from sqlplus), but when I run it from script it receive an error ORA-20200. Of course it's obvious that this snap_id exist because I select it from statspack view! Question is, why this code works when I execute it line by line from sqlplus session, but doesn't work when it's run from script? Anyone have such problem?

Best.
This post has been answered by 815328 on Aug 4 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 1 2011
Added on Aug 3 2011
7 comments
2,643 views