Skip to Main Content

SQL & PL/SQL

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!

Select into a variable

486801May 25 2006 — edited May 25 2006
Hi,

I am trying to write a script that will find out the min(snap_id) and max(snap_id) from STATS$SNAPSHOT. THis script will pass these two variables when sppurge.sql is run, so it will input the lowsnap and hisnap and delete the old snapshots.

So here is my script, I know it is wrong, can someone help me to fix it?

-----------------------------------
SET VERIFY OFF
SET FEEDBACK OFF

SET SERVEROUTPUT ON
DECLARE
min NUMBER := 0;
BEGIN
select min(snap_id)
into min
from STATS$SNAPSHOT
where STARTUP_TIME < (sysdate-21)
order by snap_id;

DBMS_OUTPUT.PUT( min ); DBMS_OUTPUT.NEW_LINE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
/
---------------------------

Thanks in advance.

Robert
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2006
Added on May 25 2006
6 comments
414 views