Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the structures of PostgreSQL loops

Shulou Source: shulou.com Published: 2022-05-31 15:23:58 10月04日 Update

This article mainly explains "what is the structure of PostgreSQL loop". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the structure of PostgreSQL loop is.

1. Basic LOOP statements

Using EXIT...WHEN to end the loop operation

DECLARE I NUMBER: =-3; BEGIN LOOP DBMS_OUTPUT.PUT_LINE ('I ='| | I); I: = I + 1; EXIT test_loop WHEN I > 3; END LOOP; DBMS_OUTPUT.PUT_LINE ('LOOP loop is over!') ; END; /

Use the if. Exit statement to end the loop

DECLARE I NUMBER: =-3; BEGIN LOOP DBMS_OUTPUT.PUT_LINE ('I ='| | I); I: = I + 1; IF I > 3 THEN EXIT TEST_LOOP; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE ('LOOP cycle is over!') ; END; / II, WHILE...LOOP structure DECLARE I NUMBER: =-3; BEGIN WHILE (I < 4) LOOP DBMS_OUTPUT.PUT_LINE ('I ='| I); I: = I + 1; END LOOP; DBMS_OUTPUT.PUT_LINE ('LOOP loop is over!') END; / III, FOR...LOOP structure DECLARE BEGIN FOR I IN-3.. 3 LOOP DBMS_OUTPUT.PUT_LINE ('I ='| | I); END LOOP; DBMS_OUTPUT.PUT_LINE ('LOOP loop is over!') ; END; / Thank you for your reading, the above is the content of "what is the structure of the PostgreSQL loop?" after the study of this article, I believe you have a deeper understanding of what the structure of the PostgreSQL loop has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Loops structure learning content sentences that is ideas situations articles more knowledge knowledge points articles follow questions practice push research verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno MySQL macOS Docker