WAITFOR Statement

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

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

WAITFOR {
   DELAY time_value | TIME time_value }
   [ CHECK EVERY integer }
   [ AFTER MESSAGE BREAK ]

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

The WAITFOR statement wakes up periodically (every 5 seconds by default) to check if it has been canceled or if messages have been received. If neither of these has happened, the statement continues to wait.

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

(back to top)

  • SQL—Vendor extension to ISO/ANSI SQL grammar.
  • SAP Sybase Database product—This statement is also implemented by Adaptive Server.

Permissions

(back to top)

None

Related reference
CREATE EVENT Statement