troubleshooting Question

loop in oracle not fetching all records, 1st record is fetched.

Avatar of anumoses
anumosesFlag for United States of America asked on
Oracle Database
21 Comments1 Solution536 ViewsLast Modified:
Cursor C1 is
select e.mail_last_name||','||e.first_name as Name,
                     d.area_cd,
           d.division_cd||'  '||e.department_id as div_dept,
           e.employee_id,
                     e.social_security_no,
           e.position_cd,
           p.position_name,
         --e.hours_available
           ds.start_time,
           ds.start_hours||' '||start_minutes as start_tm,
           ds.end_time
  from department d,employee e,dept_staff ds, position p
 where d.department_id = e.department_id
    and d.division_cd = case when :hdr.division_cd = 'A' then d.division_cd else :hdr.division_cd end
   and e.position_cd = p.position_cd(+)
   and e.social_security_no = ds.social_security_no
   and ds.schedule_date = '25-JUN-2011'
   and ds.site_code = 'CS17';

Begin

Open C1;
first_record;
loop
Fetch C1 into
:dtl.emp_name,
:dtl.area_cd,
:dtl.div_dept,
:dtl.emp_id,
:dtl.social_security_no,
:dtl.position_cd,
:dtl.position_name,
:dtl.start,
:dtl.start_time,
:dtl.end_time;
--Exit when C1%notfound;
exit when :SYSTEM.LAST_RECORD = 'TRUE';
next_record;
END LOOP;
Close C1;

End;
----------------expected results

NAME|DIV_DEPT|POSITION_CD|POSITION_NAME

Baines,Nichole|W  5|PHMB|Mobile Phleboto
Bekoe,Stephen|W  5|PHMB|Mobile Phleboto
Guitierrez,Paige|W  5|PHTR|Phleb Training
Johnson,Teressa|W  5|SRPM|Sr Phlb - Mbl
King,Sonja|W  5|TLMB|Mobile Teamlead
Lemke,Mandy|W  5|PHMB|Mobile Phleboto
White,Katrina|W  5|PHMB|Mobile Phleboto



screen-print.JPG
ASKER CERTIFIED SOLUTION
flow01
IT-specialist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros