Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-19 Thread mariusz
hello, On Tue, 2016-01-19 at 10:37 +1300, drum.lu...@gmail.com wrote: > I've created a function that allows me to do an huge update. > > But I need to limit this function. I need to do 50k rows (example) and > then stop it. After that I need to continue from the rows that I've > stopped... I'll

Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-19 Thread Harald Fuchs
"drum.lu...@gmail.com" writes: > So, the new plan is: > > 1 - Select 50.000 rows and gives it a batch number. > 2 - Select *MORE* 50,000 rows and gives it a *NEW* batch number. > 3 - Select *MORE* 50,000 rows and gives it a *NEW* batch number. Why so complicated? Here's a simplified example:

[GENERAL] Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-18 Thread drum.lu...@gmail.com
On 19 January 2016 at 11:44, dinesh kumar wrote: > Hello, > > On Mon, Jan 18, 2016 at 1:37 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> I've created a function that allows me to do an huge update. >> >> But I need to limit this function. I need to do 50k rows (example) and >> th

[GENERAL] Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-18 Thread dinesh kumar
Hello, On Mon, Jan 18, 2016 at 1:37 PM, drum.lu...@gmail.com wrote: > I've created a function that allows me to do an huge update. > > But I need to limit this function. I need to do 50k rows (example) and > then stop it. After that I need to continue from the rows that I've > stopped... I'll ha

[GENERAL] Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-18 Thread drum.lu...@gmail.com
> > It is customary to restrict emails to a single list or at least make > others aware when you do have a legitmate need to cross-post. > > Specifically your post on -admin <“Break” in plpgsql Function - PostgreSQL > 9.2> > > Yes, it didn't belong on -admin in the first place but posting it here >

[GENERAL] Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-18 Thread David G. Johnston
On Mon, Jan 18, 2016 at 2:37 PM, drum.lu...@gmail.com wrote: > I've created a function that allows me to do an huge update. > > But I need to limit this function. I need to do 50k rows (example) and > then stop it. After that I need to continue from the rows that I've > stopped... I'll have to mo

[GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

2016-01-18 Thread drum.lu...@gmail.com
I've created a function that allows me to do an huge update. But I need to limit this function. I need to do 50k rows (example) and then stop it. After that I need to continue from the rows that I've stopped... I'll have to modify the call function *select batch_number()* as well. How can I do th

Re: [GENERAL] Loop

2009-09-12 Thread Alban Hertroys
On 12 Sep 2009, at 11:58, Alban Hertroys wrote: On 12 Sep 2009, at 24:17, db.subscripti...@shepherdhill.biz wrote: Hi, I have a loop of the form: FOR rec IN SELECT code FROM staff WHERE shiftgroup = NEW.groupe ORDER BY code LOOP WHILE sdate <= NEW.todate LOOP SELECT IN

Re: [GENERAL] Loop

2009-09-12 Thread Alban Hertroys
On 12 Sep 2009, at 24:17, db.subscripti...@shepherdhill.biz wrote: Hi, I have a loop of the form: FOR rec IN SELECT code FROM staff WHERE shiftgroup = NEW.groupe ORDER BY code LOOP WHILE sdate <= NEW.todate LOOP SELECT INTO starty,endy,nday resumetime,closetime,nextday F

[GENERAL] Loop

2009-09-11 Thread db . subscriptions
Hi, I have a loop of the form: FOR rec IN SELECT code FROM staff WHERE shiftgroup = NEW.groupe ORDER BY code LOOP WHILE sdate <= NEW.todate LOOP SELECT INTO starty,endy,nday resumetime,closetime,nextday FROM shifts WHERE shift = NEW.shift; restim

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Sam Mason
On Wed, Aug 27, 2008 at 05:14:46PM +0200, Ivan Sergio Borgonovo wrote: > On Wed, 27 Aug 2008 14:47:24 +0100 Sam Mason <[EMAIL PROTECTED]> wrote: > > OK, so it's the UPDATE that's taking the time. I'm not experienced > > enough to say why though. > > I can't get it either. > I'd say that: > - use

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Ivan Sergio Borgonovo
On Wed, 27 Aug 2008 14:47:24 +0100 Sam Mason <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 02:58:18PM +0200, Ivan Sergio Borgonovo > wrote: > > On Wed, 27 Aug 2008 12:45:42 +0100 Sam Mason <[EMAIL PROTECTED]> > > wrote: > > > Have you been vacuuming (non-full) between runs? and as always, >

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Sam Mason
On Wed, Aug 27, 2008 at 02:58:18PM +0200, Ivan Sergio Borgonovo wrote: > On Wed, 27 Aug 2008 12:45:42 +0100 Sam Mason <[EMAIL PROTECTED]> wrote: > > Have you been vacuuming (non-full) between runs? and as always, > > are the stats reasonably up to date? > > there is autovacuum running regularly an

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Ivan Sergio Borgonovo
On Wed, 27 Aug 2008 12:45:42 +0100 Sam Mason <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 01:19:30PM +0200, Ivan Sergio Borgonovo > wrote: > > but this looks much slower than the function: > > function: 113sec > > vs. > > single statement: 488sec > > I repeated the test 3 times with simila

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Sam Mason
On Wed, Aug 27, 2008 at 01:19:30PM +0200, Ivan Sergio Borgonovo wrote: > but this looks much slower than the function: > function: 113sec > vs. > single statement: 488sec > I repeated the test 3 times with similar results. Have you been vacuuming (non-full) between runs? and as always, are the sta

Re: [GENERAL] loop vs. aggregate was: update and group by/aggregate

2008-08-27 Thread Ivan Sergio Borgonovo
On Wed, 27 Aug 2008 10:32:43 +0200 Ivan Sergio Borgonovo <[EMAIL PROTECTED]> wrote: > create or replace function UpdateAuthors() > returns void > as > $$ > declare > _row record; > _ItemID bigint; > _Authors varchar(1024); > _Name varchar(50); > begin > _Authors:=''; > _ItemID:=null; >

Re: [GENERAL] Loop through all views with PHP

2007-06-18 Thread A. Kretschmer
am Mon, dem 18.06.2007, um 14:59:34 +0200 mailte Stefan Schwarzer folgendes: > Hi there, > > my app is creating views for a certain task; now, I would like to run > on a regular basis a script which deletes these views. As they are > named with the date/hour/min/sec-appendix to make each view

Re: [GENERAL] Loop through all views with PHP

2007-06-18 Thread Francisco Reyes
Stefan Schwarzer writes: Is there any way via PHP to loop through the whole set of views to delete those with a specific name? See pg_views. In particular the viewname column. ---(end of broadcast)--- TIP 5: don't forget to increase your free

[GENERAL] Loop through all views with PHP

2007-06-18 Thread Stefan Schwarzer
Hi there, my app is creating views for a certain task; now, I would like to run on a regular basis a script which deletes these views. As they are named with the date/hour/min/sec-appendix to make each view unique, I don't know the names myself (Ok, I could stock the names in a separate t

Re: [GENERAL] Loop plpgsql recordset

2007-01-29 Thread Angva
This is how I loop through a record: for rec in (select * from yourtable where somevar=3) loop --output the record raise notice '%', rec.somevar end loop; -- Mark On Jan 25, 2:46 pm, [EMAIL PROTECTED] ("Furesz Peter") wrote: > Hello, > > How can I loop a PL/PgSQL recorset variable? The

Re: [GENERAL] Loop plpgsql recordset

2007-01-29 Thread Alban Hertroys
Furesz Peter wrote: > FOR v_tmp IN v_tmp_regi LOOP > --I would like to work here with the old recordset! > END LOOP; > ^^ >-- This is not working !!! How do you expect to loop one record? In a recent thread (with a remarkably similar questio

Re: [GENERAL] Loop plpgsql recordset

2007-01-26 Thread George Weaver
On Thursday, January 25 Furesz Peter wrote: >How can I loop a PL/PgSQL recorset variable? The example: >DECLARE >v_tmp_regi RECORD; >v_tmp RECORD; >BEGIN > SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE >sf.termekfajta_id= > a_termekfajta_id AND sf.mar

[GENERAL] Loop plpgsql recordset

2007-01-26 Thread Furesz Peter
Hello, How can I loop a PL/PgSQL recorset variable? The example: DECLARE v_tmp_regi RECORD; v_tmp RECORD; BEGIN SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE sf.termekfajta_id= a_termekfajta_id AND sf.marka_id=a_marka_id; DELETE FROM sulyoz

Re: [GENERAL] loop plpgsql recordset variable

2007-01-25 Thread Merlin Moncure
On 1/25/07, Furesz Peter <[EMAIL PROTECTED]> wrote: How can I loop a PL/PgSQL recorset variable? The example: DECLARE v_tmp_regi RECORD; v_tmp RECORD; BEGIN SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE sf.termekfajta_id= a_termekfajta_id AND sf.mar

[GENERAL] loop plpgsql recordset variable

2007-01-25 Thread Furesz Peter
Hello, How can I loop a PL/PgSQL recorset variable? The example: DECLARE v_tmp_regi RECORD; v_tmp RECORD; BEGIN SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE sf.termekfajta_id= a_termekfajta_id AND sf.marka_id=a_marka_id; DELETE FROM sulyozas_fu

Re: [GENERAL] Loop in loop

2007-01-22 Thread Moritz Bayer
Hi Andreas, if it is possible, can you tell me what error I 've put in my first function? Thanks, Mo

[GENERAL] Loop in loop

2007-01-22 Thread Moritz Bayer
Hello group, I've got a new problem where I hope someone can give me a solution. I have witten a function which should give back a type created by me. To get the data into the type, I have to go through a loop, which holds other loops. Simplified (not really), it looks like this: CREATE OR REPL

Re: [GENERAL] Loop in loop

2007-01-22 Thread George Weaver
Original Message From: Moritz Bayer >But still the question: >Is it possible to put a loop into a loop? Or doesn't it make sense at all? I'm not sure what the OP was about, but Yes, it it possible to put a loop into a loop. See: http://www.postgresql.org/docs/8.2/static/plpgsql-control

Re: [GENERAL] Loop in loop

2007-01-22 Thread A. Kretschmer
am Mon, dem 22.01.2007, um 15:58:32 +0100 mailte Moritz Bayer folgendes: > > But still the question: > Is it possible to put a loop into a loop? Or doesn't it make sense at all? Yes, is possible, why not? And sometimes it make sense... Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/

Re: [GENERAL] Loop in loop

2007-01-22 Thread Moritz Bayer
OK, this looks better: CREATE OR REPLACE FUNCTION getregistrationtagging() RETURNS SETOF ty_usertracking AS $BODY$ DECLARE objReturn ty_usertracking%rowtype; BEGIN for objReturn IN SELECT date_part('day',trackdate) as ty_day, date_part('month',trackdate) as ty_month

Re: [GENERAL] loop with circular updates

2006-07-30 Thread Jessica M Salmon
AM cc pgsql-general@postgresql.org Subject Re: [GENERAL] loop with circular

Re: [GENERAL] loop with circular updates

2006-07-28 Thread Tom Lane
Jessica M Salmon <[EMAIL PROTECTED]> writes: > -is it true that when looping over query results in a plpgsql > for..in..execute loop, several records are stored in memory at one time? Yes, but that's got nothing to do with your issue. > -if I then update one of the records currently i

Re: [GENERAL] loop with circular updates

2006-07-28 Thread Jessica M Salmon
Subject Re: [GENERAL] loop with circular

Re: [GENERAL] loop with circular updates

2006-07-26 Thread Kenneth Downs
Jessica M Salmon wrote: Hi All. I'm writing a plpgsql function that creates a table and loops over the items in that table, using a FOR ... IN EXECUTE ... loop. The thing is, on each iteration I update the table over which I am looping. Sometimes, the result of this update makes it no longer ne

[GENERAL] loop with circular updates

2006-07-26 Thread Jessica M Salmon
Hi All. I'm writing a plpgsql function that creates a table and loops over the items in that table, using a FOR ... IN EXECUTE ... loop. The thing is, on each iteration I update the table over which I am looping. Sometimes, the result of this update makes it no longer necessary/desirable to proce

[GENERAL] loop on trigger

2001-04-18 Thread mgermoni
following your indication I found what I was looking for...Thank you. I made a simple trigger/function that: on insert check if a particular field is already on one table if not it will procede to make the insert otherwise not. But it goes on loop. Now just because I do not have experience, I'm