Loop

From: db(dot)subscriptions(at)shepherdhill(dot)biz
To: pgsql-general(at)postgresql(dot)org
Subject: Loop
Date: 2009-09-11 22:17:27
Message-ID: 20090911231727.wgkyjgo9kwsck4ks@webmail.shepherdhill.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;
restime := sdate + starty;

IF nday = true THEN
clstime := sdate + interval '1 day' + endy;
ELSE
clstime := sdate + endy;
END IF;

INSERT INTO shiftsexp(id,staff,resumetime,closetime)
VALUES(NEW.id,rec.code,restime,clstime);
sdate := sdate + interval '1 day';
END LOOP;
END LOOP;

Surprisingly, the outer loop (For .. Loop) does not loop while only
the WHILE ... Loop works.

Any hint would be appreciated.

Regards,
Chris.

Responses

  • Re: Loop at 2009-09-12 09:58:31 from Alban Hertroys

Browse pgsql-general by date

  From Date Subject
Next Message Ehsan Haq 2009-09-12 02:30:15 Re: Getting Out Parameter in the application using libpq
Previous Message Vikram Patil 2009-09-11 22:15:05 Issue regarding permissions on Windows 2003 server