Handling of Rows from a Queue Table | VantageCloud Lake - Rules for Consuming Rows from a Queue - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530
The following rules and recommendations apply to consuming rows from a queue table.
  • To consume rows from a queue table, specify the AND CONSUME TOP 1 keywords in your SELECT statement. The AND CONSUME keywords indicate that the request is a consume mode request, while TOP 1 indicates that the oldest row from the queue table is to be retrieved.

    The following example consumes a row from a queue table named shopping_cart.

    SELECT AND CONSUME TOP 1 *
    FROM shopping_cart;
  • You can also consume rows from stored procedures and embedded SQL applications that use the INTO clause to assign the values from a row to host or local variables.
  • Put any action taken based on consuming a row from a queue table in the same transaction as the consume mode SELECT operation on that same queue table. This makes sure that both the row consumption and the action taken on that queue table are committed together, so no row or action for that queue table is lost.

    If no action is to be taken, isolate any SELECT AND CONSUME statement as the only request in a transaction.

  • A multiple-statement request must contain only one consume mode SELECT statement.
  • A trigger can call a stored procedure that consumes a row from a queue table.