Example: Retrieving Rows from the Data Dictionary and Writing Them to an External Queue on a Client System - Analytics Database - Teradata Vantage

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

Now consider a somewhat broader use of the UDF defined in Example: Using a UDF to Write a Message to an External Queue. In this example, you retrieve dictionary information from within Vantage and write it to an external MQ queue on a client system.

To do this, you invoke the write_mq UDF for each row found in DBC.Tables that meets the requirements specified in the SELECT request WHERE clause. The SELECT request concatenates the database and table names, creating a VARCHAR string that becomes the input argument to the UDF, which then writes the concatenated databasename.tablename text as a message to the MQ queue.

     SELECT COUNT(*) AS sent_msgs 
     FROM 
   (SELECT write_mq
      ('queue.manager.1','QUEUE1','CHANNEL1/TCP/153.64.119.177',
         Trim(databasename)||'.'||trim(TableName)) AS c1
       FROM DBC.Tables 
        WHERE TableKind = 'T')T;

What this example illustrates is the ease of sending an entire result set of an arbitrary SQL request to a queue that is completely outside Vantage.