Re: Loop

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Loop
Дата
Msg-id C3E00FB4-C312-4207-94EA-95485867C190@solfertje.student.utwente.nl
обсуждение исходный текст
Ответ на Loop  (db.subscriptions@shepherdhill.biz)
Ответы Re: Loop  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
On 12 Sep 2009, at 24:17, db.subscriptions@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 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.

What makes you think that? There's nothing in your code that uses the
record from your outer loop, so how do you know it doesn't loop? Did
you raise notices to check? Why do you even have that loop, it doesn't
appear to serve a purpose?

> Any hint would be appreciated.
>
> Regards,
> Chris.

Alban Hertroys

--
Screwing up is the best way to attach something to the ceiling.


!DSPAM:737,4aab70c813781789017984!



В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: Alternative to temp tables?
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Loop