troubleshooting Question

oracle - query to delete from the table

Avatar of anumoses
anumosesFlag for United States of America asked on
Oracle Database
5 Comments3 Solutions426 ViewsLast Modified:
select a.site_code
   from dept_staff a,sites b
where a.site_code = b.site_code
    and schedule_date = '12-feb-2012'
    and reason_code = 'SH'
    and MOBILE_OR_SUBCENTER = 'M';
--------------

SITE_CODE
MR14
CW31
OF03
CY21
RL02
CW31
CY21
CY21
A262
RL02
OF03
OF03
RL02
CY21
RL02
CY21
CW31
OF03
OF03
CW31
CY21
MR14
OF03
RL02
OF03
CW31
RL02
RL02
MR14
CY21
RL02
OF03
MR14
A262
OF03
RL02
--------------
select count(a.site_code) into v_site_code_count
  from dept_staff a,sites b
 where a.site_code = b.site_code
   and schedule_date = '12-feb-2012'
   and reason_code = 'SH'
   and MOBILE_OR_SUBCENTER = 'M';
If v_site_code_count > 0 then       
case msgbox.show('Conflicting Dates','A schedule exists for this chosen week.'||chr(10)||'Do you want to Delete?', 'note', 'NO', 'YES')
 when ALERT_BUTTON2 then
 msgbox.show('Delete', 'Deleting conflicting schedules..., Please wait....', 'ok');

delete from dept_staff
where schedule_date = :date_screen.sunday_date
and site_code = .............;

                          commit;
My question is how do I loop through all the site codes? for that schedule_date and for that site code, I have to delete from dept_staff.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 5 Comments.
Join the Community
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 3 Answers and 5 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