例: 検索CASEでの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

以下の例は、検索CASE文の条件式でFORループ別名を使用する様子を示しています。

CREATE PROCEDURE spSample()
Label1:BEGIN
    FOR RowPointer AS
        c_employee CURSOR FOR
        SELECT DeptNo AS c_DeptNo,
            employeeid AS c_empid FROM Employee
    DO
        CASE
     WHEN RowPointer.c_DeptNo > 10 THEN
        INSERT INTO Dept VALUES (RowPointer.c_DeptNo,
                                RowPointer.c_empid) ;
     WHEN RowPointer.c_DeptNo <= 10 THEN
        UPDATE Employee
           SET DeptNo = RowPointer.c_DeptNo + 10 ;
        INSERT INTO Dept VALUES (RowPointer.c_DeptNo,
                                RowPointer.c_empid)
   END CASE;
    END FOR;
END Label1;