Re: [SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
I rewritte the Jonah's function to: FOR iter IN 1 .. num_iter LOOP -- some computations INSERT INTO carga (descricao) VALUES ('CardPass'); END LOOP; My ID is now() by default And it was in 23sec After I changed the insert to: INSERT INTO carga (id,descricao) VALUES (

Re: [SQL] For loop

2007-03-13 Thread Alvaro Herrera
Ezequias R. da Rocha wrote: > Thank you all. The function from Jonah solves my problem. > > Just a simple question: > > One million of inserctions in *28,8* seconds with this kind of data > (timestamp|character varring (50)) is a good performance ? > > I let my questions to DBAs from PostgreSQ

Re: [SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
Thank you all. The function from Jonah solves my problem. Just a simple question: One million of inserctions in *28,8* seconds with this kind of data (timestamp|character varring (50)) is a good performance ? I let my questions to DBAs from PostgreSQL. Sincerely Ezequias Adrian Klaver escre

[SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
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 ---(end

Re: [SQL] For loop

2007-03-13 Thread Adrian Klaver
On Tuesday 13 March 2007 6:30 am, Ezequias R. da Rocha wrote: > I quetion one more time. I must have a function ? Isn't another way to > implement it without using functions ? > > Ezequias > > Bart Degryse escreveu: > > Please post your complete CREATE FUNCTION statement. Error code 42601 > > refer

Re: [SQL] For loop

2007-03-13 Thread A. Kretschmer
am Tue, dem 13.03.2007, um 10:30:59 -0300 mailte Ezequias R. da Rocha folgendes: > I quetion one more time. I must have a function ? Isn't another way to > implement it without using functions ? Yes, you need a function. SQL doesn't know LOOPs. And, please, no silly fullquote. [100 lines dro

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
AFAK you can also use them in eg CREATE TRIGGER and on the psql command prompt. What are you trying to accomplish. When we understand that, maybe we can point you in the right direction. >>> "Ezequias R. da Rocha" <[EMAIL PROTECTED]> 2007-03-13 14:30 >>> I quetion one more time. I must have a fun

Re: [SQL] For loop

2007-03-13 Thread Alvaro Herrera
Ezequias R. da Rocha wrote: > I quetion one more time. I must have a function ? Isn't another way to > implement it without using functions ? The syntax you show is plpgsql. You cannot use that without a function. (The alternative would be to script the bulk insertion client-side, which I'd thin

Re: [SQL] For loop

2007-03-13 Thread Jonah H. Harris
On 3/13/07, Ezequias R. da Rocha <[EMAIL PROTECTED]> wrote: I quetion one more time. I must have a function ? Isn't another way to implement it without using functions ? Not in PostgreSQL. Here's a sample of something similar to what you were doing. CREATE LANGUAGE plpgsql; CREATE TABLE carg

Re: [SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
I quetion one more time. I must have a function ? Isn't another way to implement it without using functions ? Ezequias Bart Degryse escreveu: Please post your complete CREATE FUNCTION statement. Error code 42601 refers to some syntax error which probably occurs just before you start looping. T

Re: [SQL] For loop

2007-03-13 Thread Adrian Klaver
On Tuesday 13 March 2007 6:19 am, Ezequias R. da Rocha wrote: > They are not working well. > > Allways the same error. > > (if while) > ERROR: syntax error at or near "WHILE" > SQL state: 42601 > Character: 1 > > (if for) > > ERROR: syntax error at or near "FOR" > SQL state: 42601 > Character: 1 >

Re: [SQL] For loop

2007-03-13 Thread Alvaro Herrera
Ezequias R. da Rocha wrote: > They are not working well. > > Allways the same error. > > (if while) > ERROR: syntax error at or near "WHILE" > SQL state: 42601 > Character: 1 You may have a problem in the code just _before_ these lines. -- Alvaro Herrerahttp://w

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
Please post your complete CREATE FUNCTION statement. Error code 42601 refers to some syntax error which probably occurs just before you start looping. To find it I need to see more code. Please don't mail me directly. Only mail to pgsql-sql@postgresql.org >>> "Ezequias R. da Rocha" <[EMAIL PROT

Re: [SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
They are not working well. Allways the same error. (if while) ERROR: syntax error at or near "WHILE" SQL state: 42601 Character: 1 (if for) ERROR: syntax error at or near "FOR" SQL state: 42601 Character: 1 (if loop) ERROR: syntax error at or near "LOOP" SQL state: 42601 Character: 1 I instal

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
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 > 100 THEN EXIT; END LOOP; Or you can try... WHILE i <= 100 LOOP statements END LOOP; Or e

Re: [SQL] For loop

2007-03-13 Thread Ezequias R. da Rocha
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