例: FORループの更新 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLストアド プロシージャおよび埋め込みSQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
2021年7月
Language
日本語
Last Update
2021-09-23
dita:mapPath
ja-JP/vqj1592443206677.ditamap
dita:ditavalPath
ja-JP/wrg1590696035526.ditaval
dita:id
B035-1148
Product Category
Software
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;