Обсуждение: Jumping Weekends

Поиск
Список
Период
Сортировка

Jumping Weekends

От
Ranieri Mazili
Дата:
Hello,
(sorry for my poor english)

It's my first post here, and my doubt is very simple (I guess). I have a
function to populate a table, into "WHILE" I have the follow piece of code:

--Jump Weekend
IF (SELECT TO_CHAR(CAST(PRODUCTION_DATE as date),'Day')) = 'Saturday' THEN
            PRODUCTION_DATE := PRODUCTION_DATE + 2;
END IF;

It's to jump weekend adding 2 days on the variable "PRODUCTION_DATE",
the type of the variable is "DATE". But, I don't know why, it's doesn't
work properly, it's doesn't jump weekends, it's continues normally,
someone knows what's happen or what am I doing wrong?

I appreciate any help.
Thanks

Ranieri Mazili



Re: Jumping Weekends

От
Martijn van Oosterhout
Дата:
On Sun, Jun 03, 2007 at 11:11:01PM -0300, Ranieri Mazili wrote:
> Hello,
> (sorry for my poor english)
>
> It's my first post here, and my doubt is very simple (I guess). I have a
> function to populate a table, into "WHILE" I have the follow piece of code:

To get a proper answer I think you're going to have to show the actual
loop, not just these two lines. But in any case, what you're trying to
do can be done more easily as:

IF date_part(PRODUCTION_DATE, 'dow') = 6 THE
  PRODUCTION_DATE := PRODUCTION_DATE + 2;
END IF

(Please check calling convention, I wrote this of the top of my head).

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения