The following small function attempts to obtain a system resource, eg if an index should be created on a "busy" table. You wait a while and tried until the counter has reached the maximum.
CREATE OR REPLACE PROCEDURE Sleep_function IS
GotIt BOOLEAN := FALSE;
Count NUMBER := 0;
WHILE (NOT GotIt AND NOT (Count > 10)) LOOP
-- Try to get free slot, if OK, set GotIt = TRUE
-- else EXCEPTION will automatically fire.
(Insert Code here)
GotIt := TRUE;
WHEN OTHERS THEN
GotIt := FALSE;
Count := Count + 1;