SET SERVEROUTPUT ON
DECLARE

  v_drive_no   drive.driveno%TYPE;
  v_drive_name         drive.drivename%TYPE;
  v_contamt            donation.contamt%TYPE;
  v_tot_contamt        cont_info.contamt%TYPE;
  CURSOR drive_cursor IS
     SELECT driveno, drivename FROM drive
     ORDER BY driveno;
  CURSOR donation_cursor IS
     SELECT contamt FROM donation
     WHERE v_drive_no = driveno
     ORDER BY driveno;
  BEGIN
     OPEN drive_cursor;
     FETCH drive_cursor INTO v_drive_no, v_drive_name;
     WHILE drive_cursor%FOUND LOOP
       IF donation_cursor%ISOPEN THEN
         CLOSE donation_cursor;
       END IF;
       v_tot_contamt := 0;
       OPEN donation_cursor;
       FETCH donation_cursor INTO v_contamt;
       WHILE donation_cursor%FOUND LOOP
            v_tot_contamt := v_tot_contamt + v_contamt;
            dbms_output.put_line('The current amount is: '||v_tot_contamt);
            FETCH donation_cursor into v_contamt;
       END LOOP;
       INSERT into cont_info
          VALUES(v_drive_no, v_drive_name, v_tot_contamt);
       CLOSE donation_cursor;
       FETCH drive_cursor INTO v_drive_no, v_drive_name;
     END LOOP;
     CLOSE drive_cursor;
END;
/
SET SERVEROUTPUT OFF
