Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CONNECT BY LEVEL with dates

945123Sep 4 2014 — edited Sep 4 2014

I am trying to select available time slots (hours) between two date columns.

I'm using CONNECT BY LEVEL with a non-equal operator:

SELECT

      (dates.start_date_time + (level - 1) /24) start_date_time,

      dates.examiner_id

      ,dates.schedule_id   

FROM (SELECT -- bmv.schedule.common.data.AutoExaminerSchView 

       schedule_id

       ,start_date_time

       ,end_date_time

       ,examiner_id

       ,exam_status

      FROM schedule_test

      WHERE start_date_time >= TO_DATE('1/6/2014 7','MM/DD/YYYY HH24')  -- during the

    AND end_date_time <= TO_DATE('1/10/2014 15','MM/DD/YYYY HH24')  -- scheduling week

    AND exam_status = 'AVAILABLE'                               -- with available schedule

    AND ROWNUM < 2) dates

WHERE EXTRACT(HOUR FROM NUMTODSINTERVAL(   -- before the end hour (4 pm)

  (dates.start_date_time + (level - 1) /24) - TRUNC(

  (dates.start_date_time + (level - 1) /24)), 'DAY')) < TO_NUMBER(TO_CHAR(dates.end_date_time, 'HH24'))

CONNECT BY dates.start_date_time + (level - 1) /24 <= dates.end_date_time -- each hour between dates

ORDER BY (dates.start_date_time + (level - 1) /24),dates.examiner_id,dates.schedule_id;

The docs say:

Operators other than the equal sign (=) are theoretically possible in CONNECT BY clauses. However, this can result in an infinite loop through the possible combinations.

My strategy works well for one record, but when there are more than one record the results become exponentially large.

The attached SQL+ script sets up some test data and runs two sample queries.

Could someone demonstrate the correct way to select these data?

Any pointers and help are appreciated.

This post has been answered by Boneist on Sep 4 2014
Jump to Answer

Comments

Answer

To clarify - are you saying the 1st time the breakpoint wasn't honored, but now it is?

Or the breakpoint STILL isn't being used?

The most likely causes for breakpoints not 'breaking' execution are:

  • unit not compiled with debug
  • breakpoint added to a line of code that's not 'executable' (like a comment)
  • breakpoint condition evals to false


Marked as Answer by marcusafs · Sep 27 2020
marcusafs

The tutorial never says to compile for debug and I assumed the debug run button would do that, like some other tools do.  I compiled for debug and then ran debug and it broke at the break point.

Thanks.  Maybe someone could add the compile for debug the tutorial.

That step should definitely be in the lab/tutorial - sorry about that. We're going to be updating all of these for Open World, so I'll make sure this gets included.

The default compile action in the tool is 'with debug' but we don't auto compile dependent objects with debug on a debug 'start' action - which is what I think you're alluding to.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 2 2014
Added on Sep 4 2014
2 comments
1,627 views