Отчет занимает часы, чтобы показать данные, и он возвращает 0 записей - PullRequest
0 голосов
/ 31 мая 2018

Я написал запрос с использованием функциональности UNION, но не могу получить какие-либо записи.ЭТО возвращает 0 записей !!!

SELECT  
    p_mv.created_by                            createby, 
    TO_CHAR(sf_get_local(p_con.created_date,p_con.cdate_tz_code),'DD MON YY HH24:MI')  createdate,
    port.port_name                             dest, 
    p_con.pipeline_ref_id                      consolno, 
    reference_numbers.ref_num                  refnum, 
    route_s.vessel_name                        vessel, 
    route_s.flight_voyage                      voyage, 
    TO_CHAR(sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code),'DD/MM/YYYY')  destdate, 
    TO_CHAR(sf_get_local(route_s.arrival_date,route_s.arrival_date_tz_code),'DD/MM/YYYY') origindate, 
    TO_CHAR(sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code),'DD MON YY HH24:MI')  destdate, 
    TO_CHAR(sf_get_local(route_s.arrival_date,route_s.arrival_date_tz_code),'DD MON YY HH24:MI') origindate, 
    carrier.carrier_name                       carrier, 
    p_mv.pipeline_ref_id                       mawb, 
    sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code)  real_origindate ,
    DECODE(p_con.pipeline_tx_status,'O','OPEN','MFT','MANIFESTED','IS','ISSUED','CNF','CONFIRMED','OI','OPEN IMPORT','ICF','CONFIRM IMPORT','C','CLOSED','VD','VOID',p_con.pipeline_tx_status) status,
    cd_code.cd_description               consol_type



    from  pipeline             p_mv, 
    pipeline             p_con, 
    pipeline_relations   pr_cs, 
    route route_s , 
    reference_numbers, 
    carrier, 
    carrier_segment, 
    mwb_header ,
    consol ,
    port ,
    (SELECT cd_code,cd_description FROM  code_detail WHERE cm_code = '436') cd_code 

    where  (p_mv.pipeline_tx_id = pr_cs.pipeline_tx_id) AND 
    (p_mv.pipeline_tx_type = 'CS') AND 
    (pr_cs.rel_pipeline_tx_id = p_con.pipeline_tx_id(+)) AND    
    (pr_cs.rel_pipeline_tx_type(+) = 'CO' )  and 
    (p_con.pipeline_tx_id = consol.pipeline_tx_id) and 
    (p_mv.pipeline_tx_id = mwb_header.pipeline_tx_id(+)) and  
    (p_mv.pipeline_tx_id = reference_numbers.pipeline_tx_id(+)) and   
    (reference_numbers.ref_num_type(+) = 'CN') and  
    (p_mv.pipeline_tx_id = route_s.pipeline_tx_id(+)) and 
    (route_s.route_type(+) = 'S') and 
    (route_s.line_no(+) = 1) and 
    p_mv.pipeline_tx_id = carrier_segment.pipeline_tx_id(+) and 
    carrier_segment.carrier_code = carrier.carrier_code(+) and 
    p_con.port_dest = port.port_code(+) and 
    cd_code.cd_code(+) = consol.consol_service_type
    AND (p_con.orig_company_id ='570')
    AND (p_con.orig_terminal_id ='5705')
    AND p_con.pipeline_tx_status='CNF'
     AND mwb_header.transport_mode='O'

     and
/*Passing dates with the case statement to pass to different date abject at a time*/
    case '&psStatusType'
               when 'CTA' then p_con.created_date
               when 'VAD' then route_s.orgn_vsl_arvl_date
               when 'ETA' then route_s.arrival_date
               else null -- default anyway
          end 
          between to_date('&1','DD-MON-YYYY:HH24:MI:SS')
                  AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')




    UNION
    /*Using UNION functionality to join the query*/






    select
     p_con.created_by                            createby, 
    TO_CHAR(sf_get_local(p_con.created_date,p_con.cdate_tz_code),'DD MON YY HH24:MI')  createdate, 
    port.port_name                             dest, 
    p_con.pipeline_ref_id                      consolno, 
    ''                                         refnum, 
    route_s.vessel_name                        vessel, 
    route_s.flight_voyage                      voyage, 
    TO_CHAR(sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code),'DD/MM/YYYY')  destdate, 
    TO_CHAR(sf_get_local(route_s.arrival_date,route_s.arrival_date_tz_code),'DD/MM/YYYY') origindate, 
    TO_CHAR(sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code),'DD MON YY HH24:MI') destdate, 
    TO_CHAR(sf_get_local(route_s.arrival_date,route_s.arrival_date_tz_code),'DD MON YY HH24:MI') origindate, 
    carrier.carrier_name                       carrier, 
     ''                                         mawb, 
    sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code)  real_origindate ,
    DECODE(p_con.pipeline_tx_status,'O','OPEN','MFT','MANIFESTED','IS','ISSUED','CNF','CONFIRMED','OI','OPEN IMPORT','ICF','CONFIRM IMPORT','C','CLOSED','VD','VOID',p_con.pipeline_tx_status) status,
    cd_code.cd_description               consol_type 


    from pipeline p_con, 
    route route_s , 
    carrier, 
    consol ,
    port, 
    PIPELINE_RELATIONS PREL_CS, 
    (SELECT cd_code,cd_description FROM  code_detail WHERE cm_code = '436') cd_code



    where  (p_con.pipeline_tx_id = consol.pipeline_tx_id) and 
    P_CON.PIPELINE_TX_ID = PREL_CS.PIPELINE_TX_ID AND 
    PREL_CS.REL_PIPELINE_TX_TYPE ='CS' AND 
    (PREL_CS.REL_pipeline_tx_id = route_s.pipeline_tx_id(+)) and 
    (route_s.route_type(+) = 'S') and 
    (route_s.line_no(+) = 1) and 
    route_s.carrier_code = carrier.carrier_code(+) and 
    p_con.port_dest = port.port_code(+) and 
    cd_code.cd_code(+) = consol.consol_service_type and
    p_con.orig_company_id='570' and
    p_con.orig_terminal_id='5705'  and
    p_con.pipeline_tx_status='CNF' and
    consol.transport_mode = 'O'
     and

/*Passing dates with the case statement to pass to different date abject at a time*/
    case '&psStatusType'
               when 'CTA' then p_con.created_date
               when 'VAD' then route_s.orgn_vsl_arvl_date
               when 'ETA' then route_s.arrival_date
               else null -- default anyway
          end 
          between to_date('&1','DD-MON-YYYY:HH24:MI:SS')
                  AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')
...