LoginSignup
1
0

More than 5 years have passed since last update.

For loop in PostgreSQL Stored Function

Last updated at Posted at 2017-11-03

index incrementing for loop in PLpg/SQL is very similar to for loop in Ruby.

For Loop in PL/pgSQL

FOR I IN 1..10 LOOP
  -- Process
END LOOP;

For Loop in Ruby

for i in 1..10
  # process
end

Easy to memorize.

Regarding to CURSOR in PLpg/SQL, it is also similar.

FOR CR IN C LOOP
  RAISE NOTICE '%', CR.id;
END LOOP;

You can see PLpg/SQL similar loop pattern in CURSOR loop.

FOR xx IN xx LOOP
  --
END LOOP;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0