1

Is it possible to use a for loop in postgresql (Function)

3
  • 2
    Yes. Read documentaion for more details Commented Jun 16, 2018 at 10:00
  • No. Don't read the documentation Commented Jun 16, 2018 at 13:02
  • Possibly. Hope the documentation finds you Commented Jun 16, 2018 at 13:31

1 Answer 1

0

In a word - yes. The syntax is quite simple and straightforward:

FOR i IN 1..10 LOOP
    -- Do something with i
END LOOP;

You can also go backwards (by using the REVERSE keyword before specifying the range) and control the size of the step by using a BY clause.

See the documentation for the complete details.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.