Re: For loop

From: "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: "Ezequias R(dot) da Rocha" <ezequias(at)fastcon(dot)com(dot)br>
Subject: Re: For loop
Date: 2007-03-13 13:13:55
Message-ID: 45F6B1A2.A3DD.0030.0@indicator.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

As you can see in the manual (http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html) you have to remove the ; after the initial LOOP

LOOP
statements
IF i > 1000000 THEN EXIT;
END LOOP;

Or you can try...

WHILE i <= 1000000 LOOP
statements
END LOOP;

Or even... (don't initialize i in this case)

FOR i IN 1 .. 1000000 LOOP
statements
END LOOP;

>>> "Ezequias R. da Rocha" <ezequias(at)fastcon(dot)com(dot)br> 2007-03-13 14:00 >>>
Ezequias R. da Rocha escreveu:
> Hi list,
>
> I would like to test the power of processing of postgresql (and my
> server) by insert a large ammount of data on a table I have.
>
> I would like to know how to implement a For... loop . With it I think
> I could check the real power of my server.
>
> Ezequias
>
I tryed a way but it is not working. Please see it:

LOOP;
-- some computations
insert into carga (desc) values ('My Text');
IF count > 1000000 THEN
EXIT; -- exit loop
END IF;
END LOOP;

The postgresql reports the following error:
/
ERROR: syntax error at or near "LOOP"
SQL state: 42601
Character: 1/

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

In response to

  • Re: For loop at 2007-03-13 13:00:30 from Ezequias R. da Rocha

Responses

  • Re: For loop at 2007-03-13 13:19:33 from Ezequias R. da Rocha

Browse pgsql-sql by date

  From Date Subject
Next Message Ezequias R. da Rocha 2007-03-13 13:19:33 Re: For loop
Previous Message Ezequias R. da Rocha 2007-03-13 13:00:30 Re: For loop