Procedure
Use this procedure to implement multiple data targets in an APPLY statement in the executable section of a script (after the DEFINE statements).
In all of the following syntax examples, <DML spec x> represents the DML statements to be applied to data target x. For more information, see “APPLY Statement” in the Teradata Parallel Transporter Reference.
To send data to multiple targets, do the following:
1 Define an APPLY clause for the first target, specifying its consumer operator:
APPLY <DML spec> TO OPERATOR <consumer_operator>
2 Repeat Step 1 for a maximum of 32 targets, separating each APPLY clause by a comma. Omit the comma after the last one.
3 Define one or more sources with any combination of the following:
Use the following syntax to define multiple sources:
SELECT <column_list> FROM <producer_operator1>
UNION ALL
SELECT <column_list> FROM <producer_operator2>
UNION ALL
SELECT <column_list> FROM <producer_operator3>
For more information about the required and optional attributes for the APPLY clause, see “APPLY Statement” in the Teradata Parallel Transporter Reference.
For more information about the UNION ALL option, see “UNION ALL: Combining Data from Multiple Sources” on page 221.
Example
The following examples compare a single APPLY clause to multiple APPLY specifications. The examples use the syntax discussed in the previous procedure:
APPLY ('INSERT INTO EMP_TARGET1 (:EMP_ID, :EMP_LNAME, :EMP_FNAME, :EMP_DEP);') TO OPERATOR (LOAD_OPERATOR_1)
SELECT * FROM OPERATOR (EXPORT_OPERATOR_1);
APPLY ( 'UPDATE table1 SET C2 = :col2 WHERE C1 = :col1;', 'INSERT
INTO table2 ( :col1, :col2, …)' ) TO OPERATOR ( UPDATE_OPERATOR () [2])
,APPLY ( 'INSERT INTO table3 ( :col1, :col2, …)' ) TO OPERATOR (
LOAD_OPERATOR () [3] ATTR(….))
SELECT * FROM OPERATOR (EXPORT_OPERATOR_1);