Wait function for PL/SQL