--- title: 'PL/pgSQL Loop Statements' page_title: 'PL/pgSQL Loop Statements' page_description: 'in this tutorial, we will introduce you to various kinds of PL/pgSQL loop statements that execute a block of statements repeatedly.' prev_url: 'https://www.postgresqltutorial.com/postgresql-plpgsql/plpgsql-loop-statements/' ogImage: '' updatedOn: '2024-03-19T03:57:07+00:00' enableTableOfContents: true previousLink: title: 'PL/pgSQL CASE Statement' slug: 'postgresql-plpgsql/plpgsql-case-statement' nextLink: title: 'PL/pgSQL While Loop' slug: 'postgresql-plpgsql/pl-pgsql-while-loop' --- **Summary**: in this tutorial, you will learn about the PL/pgSQL loop statement that executes a block of code repeatedly. ## Introduction to PL/pgSQL Loop statement The `loop` defines an unconditional loop that executes a block of code repeatedly until terminated by an `exit` or `return` statement. The following illustrates the syntax of the `loop` statement: ```sqlsql <