例: SQLプロシージャからのSQL UDFの呼び出し - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLデータ定義言語 構文規則および例

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
2021年1月
Language
日本語
Last Update
2021-03-30
dita:mapPath
ja-JP/ncd1596241368722.ditamap
dita:ditavalPath
ja-JP/ncd1596241368722.ditaval
dita:id
B035-1144
Product Category
Software
Teradata Vantage

次の例は、SQL UDF common_value_expressionを数回にわたって呼び出します。

     CREATE PROCEDURE spAccount (
       IN  p2 INTEGER, 
       OUT p1 CHARACTER(30))
     L1: BEGIN
       DECLARE i INTEGER;
       DECLARE i1 INTEGER;
       DECLARE DeptCursor CURSOR FOR
       SELECT DeptName from Department 
       WHERE test.common_value_expression(DeptNo, 0) = 25;
       DECLARE CONTINUE HANDLER FOR SQLSTATE VALUE '23505'
     L2: BEGIN
       SET i1 = p2;
       SET p1='Failed To Insert Row';
     END L2;
     L3: BEGIN
       INSERT INTO table_1
       VALUES(1, test.common_value_expression(1,2));
       IF SQLCODE <> 0 THEN LEAVE L1;
     END L3;
       INSERT INTO table_2
       VALUES(2, test.common_value_expression(2,3));
     END L1;