当前位置:网站首页>PostgreSQL statement

PostgreSQL statement

2022-06-11 03:36:00 Full of grain

IF Conditional statements

  1. IF ... THEN...END IF;
  2. IF ... THEN ... ELSE...END IF;
  3. IF ... THEN ... ELSEIF ... THEN ... END IF;
  4. IF ... THEN ... ELSEIF ... THEN ... ELSE...END IF; 

LOOP Loop statement

1、 Use IF Exit loop

        Loop

                Logic block

        IF… THEN

                EXIT ; 

        END IF;

        END LOOP;

2、 Use WHEN Exit loop

        LOOP
            EXIT WHEN Conditions ;
            CONTINUE WHEN The subsequent logic does not execute the condition of directly entering the next iteration ;
            Logic block
        END LOOP;

3、 Use  CONTINUE The subsequent logic will not be executed this time and will directly enter the next iteration

        LOOP
            CONTINUE WHEN Conditions ;
            Logic block
        END LOOP;

WHILE loop  

WHILE Conditions LOOP
         Logic block
 END LOOP;

FOR loop

FOR A loop that iterates over a range of integer values

1、 Iterating from small to large
    FOR item_int IN 1..10 LOOP
        Logic block
    END LOOP;

2、 Iterating from large to small

    FOR item_int IN REVERSE 10..1 LOOP
        Logic block
    END LOOP;

Be careful : If the lower bound is greater than the upper bound ( Or in REVERSE Less than ), Then the loop body will not be executed at all . And will not throw any errors .

原网站

版权声明
本文为[Full of grain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110314411250.html