> This page location: PostgreSQL PL/pgSQL > CONTINUE Statement
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PL/pgSQL Continue Statement

**Summary**: in this tutorial, you will learn how to use the PL/pgSQL `continue` statement to control the loop.

## Introduction to PL/pgSQL continue statement

The `continue` statement prematurely skips the current iteration of the loop and starts the next one.

In practice, you can use the `continue` statement within the loops including [unconditional loops,](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-loop-statements) [while loops](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-while-loop), and [for loops](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-for-loop).

Here's the syntax of the `continue` statement:

```sql
continue [loop_label] [when condition]
```

In this syntax, the `loop_label` and `when condition` are optional.

The `loop_label` is the label of the loop that you want to skip the current iteration. If you omit the `loop_label`, the `continue` statement skips the current iteration of the loop. If you specify a loop label, the `continue` statement skips the current iteration of that loop.

The `condition` is a boolean expression that specifies the condition to skip the current iteration of the loop. If the `condition` is `true`, then the `continue` will skip the current loop iteration.

## PL/pgSQL Continue statement example

The following example uses the `continue` statement in an unconditional loop to print out the odd numbers from 1 to 10:

```plsql
do
$$
declare
   counter int = 0;
begin

  loop
     counter = counter + 1;

	 -- exit the loop if counter > 10
	 exit when counter > 10;

	 -- skip the current iteration if counter is an even number
	 continue when mod(counter,2) = 0;

	 -- print out the counter
	 raise notice '%', counter;
  end loop;
end;

$$;
```

Output:

```
NOTICE:  1
NOTICE:  3
NOTICE:  5
NOTICE:  7
NOTICE:  9
```

How it works.

- First, initialize the `counter` to zero.
- Second, increase the counter by one in each iteration. If the `counter` is greater than 10, then [exit](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-exit) the loop. If the `counter` is an even number, then skip the current iteration.

The `mod(counter,2)` returns the remainder of the division of the `counter` by two.

If it is zero, then the `counter` is an even number. All the statements between the `continue` statement and `end loop` will be skipped.

## Summary

- Use the `continue` statement to skip the current loop iteration prematurely and start a new one.

---

## Related docs (PostgreSQL PL/pgSQL)

- [Introduction](https://neon.com/postgresql/postgresql-plpgsql/introduction-to-postgresql-stored-procedures)
- [Block Structure](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-block-structure)
- [Variables](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-variables)
- [Constants](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-constants)
- [IF-ELSE Statements](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-if-else-statements)
- [CASE Statement](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-case-statement)
- [Loop Statements](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-loop-statements)
- [FOR Loop](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-for-loop)
- [WHILE Loop](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-while-loop)
- [EXIT Statement](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-exit)
- [Cursor](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-cursor)
- [Function Parameters](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-parameters)
- [Function Overloading](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-overloading)
- [Function Returns Table](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-returns-a-table)
- [Returns SETOF](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-returns-setof)
- [Record Types](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-record-types)
- [Row Types](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-row-types)
- [Error Messages](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-errors-messages)
- [Exception Handling](https://neon.com/postgresql/postgresql-plpgsql/postgresql-exception)
- [CREATE FUNCTION](https://neon.com/postgresql/postgresql-plpgsql/postgresql-create-function)
- [CREATE PROCEDURE](https://neon.com/postgresql/postgresql-plpgsql/postgresql-create-procedure)
- [DROP FUNCTION](https://neon.com/postgresql/postgresql-plpgsql/postgresql-drop-function)
- [DROP PROCEDURE](https://neon.com/postgresql/postgresql-plpgsql/postgresql-drop-procedure)
- [Stored Procedure with INOUT Parameters](https://neon.com/postgresql/postgresql-plpgsql/postgresql-stored-procedure-with-inout-parameters)
- [Introduction to Stored Procedures](https://neon.com/postgresql/postgresql-plpgsql/introduction-to-postgresql-stored-procedures)
- [SELECT INTO](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-select-into)
- [ASSERT Statement](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-assert)
- [Dollar-Quoted String Constants](https://neon.com/postgresql/postgresql-plpgsql/dollar-quoted-string-constants)
