Many a times we face a situation wherein a particular row or rows from a table are locked by some application/users and it causes our queries to not run if our query also requires the row to be locked. So here is a function which will exclude the rowids of those rows which are locked when used within a select query. Code (SQL): CREATE OR REPLACE FUNCTION find_locked_rows (v_rowid ROWID, TABLE_NAME VARCHAR2) RETURN ROWID IS x NUMBER; PRAGMA AUTONOMOUS_TRANSACTION; BEGIN EXECUTE IMMEDIATE 'Begin Select 1 into :x from ' || TABLE_NAME || ' where rowid =:v_rowid for update nowait; Exception When Others Then :x:=null; End;' USING OUT x, v_rowid; ROLLBACK; IF x = 1 THEN RETURN v_rowid; ELSIF x IS NULL THEN RETURN NULL; END IF; END; The basic idea is to first locate all the rows that are locked and find their ROWIDs. To locate all the locked rows a cursor is built which will try to lock each row in the table. (Select for update nowait). If it succeeds then that row is not locked by anyone and the function returns the corresponding rowid. If it fails then the row is locked so the functions returns NULL. The function takes the rowid of each record in the table and the table name as parameters.The function can be directly used in a Select Query as part of a a co-related query. Or can also be used in another pl/sql program.