DECLARE
  -- Declare variables to hold information about the students
  -- majoring in History.
  v_StudentID   students.id%TYPE;
  v_FirstName   students.first_name%TYPE;
  v_LastName    students.last_name%TYPE;
  v_rn integer;   -- Cursor to retrieve the information about History students
  CURSOR c_HistoryStudents IS
    SELECT rownum rn,id, first_name, last_name
      FROM students
      WHERE major = 'History';
BEGIN
  -- Open the cursor and initialize the active set
  OPEN c_HistoryStudents;
  LOOP
    -- Retrieve information for the next student
    FETCH c_HistoryStudents INTO v_rn,v_StudentID, v_FirstName, v_LastName;    -- Exit loop when there are no more rows to fetch
    EXIT WHEN c_HistoryStudents%NOTFOUND;
    if v_rn=100 then
      INSERT INTO registered_students (student_id, department, course)
        VALUES (v_StudentID, 'HIS', 301);    INSERT INTO temp_table (num_col, char_col)
      VALUES (v_StudentID, v_FirstName || ' ' || v_LastName);
    end if;
  END LOOP;  -- Free resources used by the cursor
  CLOSE c_HistoryStudents;  -- Commit our work
  COMMIT;
END;
/