PROMPT Creating view BAGS_NOT_LOADED_REPORT_V

CREATE OR REPLACE FORCE VIEW BAGS_NOT_LOADED_REPORT_V AS
SELECT      b.bag_tag,
            b.bag_tag1,
            b.bag_tag2a,
            b.bag_tag2b,
            LTRIM(TO_CHAR(b.bag_tag3, '000000'))                    bag_tag3,
            b.bag_destination                                       bag_dest,
            p.pax_initials,
            p.pax_surname,
            p.pax_class,
            p.pax_sequence_no                                       pax_seq,
            decode(substr(bag_report_utils.get_pre_cleared (b.bag_tag, b.pax_id),1,1),
                                   'Y','PRE_CLEARED', 'NOT SEEN') pre_cleared,
            b.loaded_status                                         loaded,
            f.flight_id,
            f.flight_no,
            f.flight_date
   FROM     bag    b,
            pax    p,
            flight f
   WHERE    b.pax_id                     = p.pax_id
   AND      p.flight_id                  = f.flight_id
   AND      b.loaded_status             != 'Y'
   AND      b.delete_marker             != 1
   AND      p.delete_marker             != 1
   AND      b.authority_to_load_dcs      = 'Y'
   AND      b.authority_to_load_brs      = 'Y'
   ORDER BY p.pax_sequence_no, b.bag_tag;

