Example: FOR-Loop Update - Teradata Vantage - Analytics Database

SQL Stored Procedures and Embedded SQL

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Publication Date
June 2022
Content Type
SQL Reference
Publication ID
B035-1148-172K
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
frc1628111662093.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
ft:sourceId
dita
dita:id
rjx1472253414573
lifecycle
latest
Product Category
Teradata Vantage™
L1:
FOR CustCursor AS c_customer CURSOR FOR
   SELECT CustomerNumber AS Number
         ,CustomerName AS Name
         ,(Amount + 10000) a
     FROM Customer
DO
   SET hCustNbr = CustCursor.Number;
   SET hCustName = CustCursor.Name;
   SET hAmount = CustCursor.a + CustCursor.a * 0.20;
   IF hAmount > 50000 THEN
   hAmount = 500000;
END IF;
UPDATE customer
   SET amount = hAmount WHERE CURRENT OF c_customer;
   INSERT INTO Cust_temp VALUES (hCustNbr,
               hCustName);
END FOR;