WAITFOR statement

Description

Delays processing for the current connection for a specified amount of time or until a given time.

Syntax

WAITFOR { DELAY time | TIME time }
time:  string

Examples

Example 1

The following example waits for three seconds:

WAITFOR DELAY '00:00:03'

Example 2

The following example waits for 0.5 seconds (500 milliseconds):

WAITFOR DELAY '00:00:00:500'

Example 3

The following example waits until 8 p.m.:

WAITFOR TIME '20:00'

Usage

If DELAY is used, processing is suspended for the given interval. If TIME is specified, processing is suspended until the server time reaches the time specified.

If the current server time is greater than the time specified, processing is suspended until that time on the following day.

WAITFOR provides an alternative to the following statement, and might be useful for customers who choose not to enable Java in the database:

call java.lang.Thread.sleep( <time_to_wait_in_millisecs> )

In many cases, scheduled events are a better choice than using WAITFOR TIME, because scheduled events execute on their own connection.


Side effects

The implementation of this statement uses a worker thread while it is waiting. This uses up one of the threads specified by the -gn server command line option.

Standards

Permissions

None.

See also

CREATE EVENT statement