pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bart Degryse <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Cc: Ezequias R. da Rocha <ezequias@fastcon.com.br>
Subject: Re: For loop
Date: Tue, 13 Mar 2007 14:13:55 +0100
Message-ID: <45F6B1A2.A3DD.0030.0@indicator.be> (raw)
In-Reply-To: <45F6A06E.7090104@fastcon.com.br>
References: <45F69D7C.4070304@fastcon.com.br>
	<45F6A06E.7090104@fastcon.com.b r>

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@fastcon.com.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

view thread (16+ messages)  latest in thread

Message-ID: <45F6B1A2.A3DD.0030.0@indicator.be>
Permalink:  ../45F6B1A2.A3DD.0030.0@indicator.be/
Also on:    postgresql.org/message-id/45F6B1A2.A3DD.0030.0@indicator.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Bart.Degryse@indicator.be, ezequias@fastcon.com.br
  Subject: Re: For loop
  In-Reply-To: <45F6B1A2.A3DD.0030.0@indicator.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox