Can a Database request automatically remove itself from the queue after a delay? I'm using table locking in my Oracle database. I have a small program with a function that locks my table, does some things and unlocks it again.  If many instances are run and requests are made simultaneously, the table locks will be queue, like updates or other table modifications would be.

In a positive spirit of bug prevention, I'm concerned that if the Database crashes or suddenly becomes unavailable for any reason, while the table is locked, the program instances in queue would be stuck there, waiting for an answer that will never come.

Obviously, getting my program frozen is undesirable. Is there any way a request can remove itself from the queue after a set time?  It there maybe a better way to do this?

If this proves to be a problem, I do know that I can use the NO WAIT parameter in my table lock, and then repeat requests for a certain time before giving up, but that seems quite inefficient and I lose the benefit of the database queue.

What do you think?
From Oracle 11gR1 you can use the WAIT instruction in DDL:

lock table t in exclusive mode wait 10;


This will wait 10 seconds before giving up.

The WAIT instruction has been available for a long time (9i) for DML:

SELECT * FROM t FOR UPDATE WAIT 10;