By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,021 Members | 912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,021 IT Pros & Developers. It's quick & easy.

Can DB2 do a select with a TimeOut if it takes too long?

P: n/a
We have a case where we want to attempt to do some processing, but if
the records are currently locked, we'd like to avoid processing (for
now, and move on to something else until the records are unlocked).

The problem is: how do we manage this?

If there was a way to check if the record was locked, that would be
ideal (i.e., ask, its locked, do something else).

Alternatively, if we could do a modification/locking action, and the
engine waits for a certain time and then times out on us, that would
also work.

Are any of these options available in DB2?

Thanks,
Chris

Jan 26 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Ahh, never mind. It appears that in 8.2, you can set the CURRENT LOCK
TIMEOUT by session to achieve what we want.

-Chris

Jan 26 '07 #2

P: n/a
ChrisC wrote:
We have a case where we want to attempt to do some processing, but if
the records are currently locked, we'd like to avoid processing (for
now, and move on to something else until the records are unlocked).

The problem is: how do we manage this?

If there was a way to check if the record was locked, that would be
ideal (i.e., ask, its locked, do something else).

Alternatively, if we could do a modification/locking action, and the
engine waits for a certain time and then times out on us, that would
also work.

Are any of these options available in DB2?
SET CURRENT LOCK TIMEOUT
http://publib.boulder.ibm.com/infoce...c/r0011874.htm

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 26 '07 #3

P: n/a
Ian
ChrisC wrote:
Ahh, never mind. It appears that in 8.2, you can set the CURRENT LOCK
TIMEOUT by session to achieve what we want.
Also note you can set the LOCKTIMEOUT database configuration parameter
to control the default timeout for all connections.

I'd suggest that setting CURRENT LOCK TIMEOUT explicitly should be the
exception, not the rule.
Jan 26 '07 #4

P: n/a
Ian wrote:
ChrisC wrote:
>Ahh, never mind. It appears that in 8.2, you can set the CURRENT LOCK
TIMEOUT by session to achieve what we want.

Also note you can set the LOCKTIMEOUT database configuration parameter
to control the default timeout for all connections.

I'd suggest that setting CURRENT LOCK TIMEOUT explicitly should be the
exception, not the rule.
Note that the lock timeout begins ticking for each lock. So if you want to
limit the overall execution time of a statement, use two threads in your
app: one thread executes the statement, and the other can be used to cancel
the execution when you deem it to take too long.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 29 '07 #5

P: n/a
Hi.

On Jan 29, 11:43 am, Knut Stolze <sto...@de.ibm.comwrote:
Note that the lock timeout begins ticking for each lock. So if you want to
limit the overall execution time of a statement, use two threads in your
app: one thread executes the statement, and the other can be used to cancel
the execution when you deem it to take too long.
This is still only available via a command line connection, right?
You can't force applications from within SQL yet (in standard DB2, at
least), right?

Thanks,
Chris

Jan 29 '07 #6

P: n/a
ChrisC wrote:
On Jan 29, 11:43 am, Knut Stolze <sto...@de.ibm.comwrote:
>Note that the lock timeout begins ticking for each lock. So if you want
to limit the overall execution time of a statement, use two threads in
your app: one thread executes the statement, and the other can be used to
cancel the execution when you deem it to take too long.
This is still only available via a command line connection, right?
You can't force applications from within SQL yet (in standard DB2, at
least), right?
I'm referring to functions like SQLCancel() in CLI (aka ODBC). JDBC has
something similar.

You cannot "cancel" an execution from the command line as far as I know.
You can only force a connection, which terminates the SQL session - not
just the statement being executed.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.