Re: For Loop w/time interval

From: ddf <oratune_at_msn.com>
Date: Fri, 21 Jun 2013 10:19:58 -0700 (PDT)
Message-ID: <0ec03dfc-d9fd-4ac6-a06e-306dc58b408b_at_googlegroups.com>



On Friday, June 21, 2013 1:22:57 AM UTC-6, kooro..._at_gmail.com wrote:
> On Tuesday, June 18, 2013 1:22:23 AM UTC+10, artm..._at_gmail.com wrote:
>
> > Hi,
>
> >
>
> >
>
> >
>
> > I need to write a FOR LOOP which uses minutes as the interval, from a start time to and end time.
>
> >
>
> >
>
> >
>
> > So, maybe something like this (pseudo english):
>
> >
>
> >
>
> >
>
> > For x IN (8:30 - 3:00 INTERVAL 1 minute) LOOP
>
> >
>
> > .
>
> >
>
> > .
>
> >
>
> > .
>
> >
>
> > END LOOP
>
> >
>
> >
>
> >
>
> > Where X will be the HH:MI that the loop is performing on. I'll need access to that HH:MI to compare it against other things.
>
> >
>
> >
>
> >
>
> > But, how to create the loop which will use the hour / minute?
>
> >
>
> >
>
> >
>
> > Thanks!
>
>
>
> Something like this (with refinement):
>
> SET SERVEROUTPUT ON
>
> DECLARE
>
> BEGIN
>
> FOR xx IN (SELECT (TRUNC(SYSDATE) + 8.5/24)+rownum/24/60 The_time
>
> FROM DUAL connect by level <= ((TRUNC(SYSDATE) + 9/24)-(TRUNC(SYSDATE) + 8.5/24))*60*24) LOOP
>
>
>
> dbms_output.put_line(to_char(xx.the_time,'HH:MI'));
>
>
>
> END LOOP;
>
> END;
>
> /

Unfortunately with that implementation the output won't be displayed until the loop has completed execution; if the OP wants a near-real-time display that won't work. Even a pipelined function won't work as it appears the loop generates values faster than the clock actually runs. Adding a sleep only delays the entire output set.

I haven't had much time to play with this to see if there is a way to implement what the OP wants but from casual inspection it appears there is not.

Maybe someone can prove me wrong.

David Fitzjarrell Received on Fri Jun 21 2013 - 19:19:58 CEST

Original text of this message