/*  procedure to add PL/SQL table onwd_flt_t of data  to
    the onward_flight table.
*/
PROMPT CREATE OR REPLACE PROCEDURE add_onward_flight

CREATE OR REPLACE PROCEDURE add_onward_flight
(
   paxid           IN   NUMBER,
   v_onward_flight IN   onward_flight_defs.onwd_flt_t 
) 
AS
   v_index BINARY_INTEGER := 0;
BEGIN  

   DELETE
     FROM onward_flight 
    WHERE paxid = pax_id;

   FOR v_index IN 1..v_onward_flight.count
   LOOP
      INSERT
        INTO onward_flight
         (pax_id,
          no,
          odate,
          dest,
          dest_order,
          class)
      VALUES
         (paxid,
          v_onward_flight(v_index).no,
          v_onward_flight(v_index).odate,
          v_onward_flight(v_index).dest,
          v_onward_flight(v_index).dest_order,
          v_onward_flight(v_index).class);
   END LOOP;

END add_onward_flight;
/
