数据仓库服务 GAUSSDB(DWS)-Procedure:LOOP

时间:2024-10-26 11:41:18

LOOP

Netezza语法

迁移后语法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
CREATE OR REPLACE PROCEDURE sp_ntz_for_loop_with_more_dots 
      ( INTEGER ) 
     RETURNS CHARACTER VARYING(ANY) 
     LANGUAGE NZPLSQL 
 AS BEGIN_PROC 
 DECLARE p_abc  INTEGER; 
         p_bcd  INTEGER; 
         p_var1 ALIAS FOR $1; 
 BEGIN 
      p_bcd := ISNULL(p_var1, 10); 
      RAISE NOTICE 'p_bcd=%', p_bcd; 
  
      FOR p_abc IN 0...(p_bcd) 
      LOOP 
           RAISE NOTICE 'hello world %', p_abc; 
      END LOOP; 
  
 END; 
 END_PROC;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE OR REPLACE FUNCTION sp_ntz_for_loop_with_more_dots 
      ( INTEGER ) 
   RETURN CHARACTER VARYING  
   AS  
         p_abc INTEGER ; 
         p_bcd  INTEGER; 
         p_var1 ALIAS FOR $1; 
  
 BEGIN 
      p_bcd := NVL(p_var1, 10); 
  
      RAISE NOTICE 'p_bcd=%', p_bcd; 
  
      FOR p_abc IN 0..(p_bcd) 
      LOOP 
           RAISE NOTICE 'hello world %', p_abc; 
  
      END LOOP; 
  
 END; 
 /
support.huaweicloud.com/tg-dws/dws_07_6823.html