PL/SQL question?

Discussion in 'OT Technology' started by SnYpR808, Mar 1, 2004.

  1. SnYpR808

    SnYpR808 Guest

    I'm having trouble writing a procedure that deletes certain entries that don't meet a prerequisite. Say I want to check a table for students who have signed up for a course 112 without having taken the prerequisite course 50. I want to search through the table and delete all the students who have signed up for the course 112 without having taken course 50. I'm having trouble with the cursor nested in the procedure. Any help?
     
  2. not familiar with pl/sql specifically, but your first step would be to post your current code, using [ code ] brackets.
     
  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    And your database layout - Students in one table, students to courses in another, course in a third? If it was me though, I'd first create a table/query (not sure if you need a temp table or not - might work without it) with all of the students taking 50, then create a delete query that selects course 112 in the students->courses table and joins that table with the query/table that was created in the previous step. Where the second table has no corresponding studentID (is null), delete the record in the first table.
     
  4. SnYpR808

    SnYpR808 Guest

    Thanks guys. 5Gen_Prelude, I didn't think of using seperate tables. That helped a lot. BTW, I'm a fellow 5th gen owner.
     
  5. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    :bigthumb:

    Sometimes you just have to break down the problem into simpler problems. I've found over the years that not only is it good from a debugging/logic side, it can also be more efficient depending on the data involved.
     

Share This Page