Stuck with the syntax of the exception.

Hello

code like this
declare
 in_use exception;
  pragma exception_init(in_use, -54);
 l_when date default sysdate ;
 l_stoptime date default sysdate + 1/(24*60);
begin
 while l_when <= l_stoptime
loop
for rec in (select indeX_name from dba_indexes where owner = 'USER' and table_name = 'TEST1')
loop
   dbms_output.put_line('in1' || l_when);
   dbms_output.put_line('in2' || l_stoptime);
   execute immediate 'alter index ' || rec.index_name  || ' rebuild ' ;
   exception 
     when in_use then null;
end loop;
dbms_output.put_line('outside');
l_when := sysdate ;
dbms_lock.sleep(3);
end loop;
end ;
/
But when you try to run the exception to
   exception
   *
ERROR at line 14:
ORA-06550: line 14, column 4:
PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
( begin case declare end exit for goto if loop mod null
pragma raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
ORA-06550: line 17, column 1:
PLS-00103: Encountered the symbol "DBMS_OUTPUT" when expecting one of the following:
end not pragma final instantiable order overriding static
member constructor map
ORA-06550: line 17, column 32:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( , * % & - + / at mod remainder rem <an identifier>
<a double-quoted delimited-identifier> <an exponent (**)> as
from into || multiset bulk
Basically, I want to continue the loop in case of full exception of resources.
Concerning
GregG

Try this:

declare
  in_use exception;
  pragma exception_init(in_use
                       ,-54);
  l_when     date default sysdate;
  l_stoptime date default sysdate + 1 /(24 * 60);
begin
  while l_when <= l_stoptime loop
    for rec in (select index_name
                  from dba_indexes
                 where owner = 'USER'
                   and table_name = 'TEST1') loop
      begin
        dbms_output.put_line('in1' || l_when);
        dbms_output.put_line('in2' || l_stoptime);
        execute immediate 'alter index ' || rec.index_name || ' rebuild ';
      exception
        when in_use then
          null;
      end;
    end loop;
    dbms_output.put_line('outside');
    l_when := sysdate;
    dbms_lock.sleep(3);
  end loop;
end;
/

Although I don't know why you're a loop around with the door. The will of the inner loop
rebuild all indexes for the specified table, then you wait 3 seconds and then build their brand new
(if door has not been reached).

Published by: Paul Horth on 18 January 2013 10:43

Tags: Database

Similar Questions

Maybe you are looking for