15.00 - Event Processing Using Queue Tables - Teradata Database

Teradata Database SQL Fundamentals

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1141-015K

Event Processing Using Queue Tables

Teradata Database provides queue tables that you can use for event processing. Queue tables are base tables with first-in-first-out (FIFO) queue properties.

When you create a queue table, you define a timestamp column. You can query the queue table to retrieve data from the row with the oldest timestamp.

Usage

An application can perform peek, FIFO push, and FIFO pop operations on queue tables.

 

To perform a …

Use the …

FIFO push

INSERT statement.

FIFO pop

SELECT AND CONSUME statement.

peek

SELECT statement.

Here is an example of how an application can process events using queue tables:

  • Define a trigger on a base table to insert a row into the queue table when the trigger fires.
  • From the application, submit a SELECT AND CONSUME statement that waits for data in the queue table.
  • When data arrives in the queue table, the waiting SELECT AND CONSUME statement returns a result to the application, which processes the event. Additionally, the row is deleted from the queue table.
  • Related Topics

     

    For more information on …

    See …

    creating queue tables

    the CREATE/REPLACE TABLE statement in SQL Data Definition Language.

    SELECT AND CONSUME

    SQL Data Manipulation Language.