From: david.rydzewski on
How about something like this....

(didn't compile or test this btw.)


declare
resource_locked exception;
pragma exception_init(resource_locked, -54);
retry number := 0;
begin

loop

begin

execute immediate 'alter index x validate structure';
return;

exception when resource_locked then

if retry > 999 then
raise_application_error( -20001, 'Could not aquire lock after
'||retry||' tries.' );
end if;

retry := retry + 1;
dbms_lock.sleep ( 0.01 );

end;

end loop;

end;
/

From: AK on
have you tried ONLINE clause of ANALYZE?