Question

Hello is there another way i can bypass this error it is complaining about one of my decode statement. So what I want is for my access_ind in the subquery to display TA500-CO =12; TA5006-HDT = 14, TA5004-HDT =13.

 DECODE (b.cfg_type, 'TA5000-CO', '12', 'TA5006-HDT', '14', 'TA5004-HDT', '13') access_ind.

I am getting a ORA-01790: expression must have same datatype as corresponding expression. Here is my sql query below.

 SELECT   a.eid, a.node_sid, a.sw_version,  
             DECODE (a.cfg_type,  
                     '7330FTTN', 'Alcatel 7330',  
                     '7340FTTU', 'Alcatel 7340',  
                     '7342GPON', 'Alcatel 7342'  
                    ) cfg_type,  
             a.ems_name,  
             DECODE (a.ems_ip_addr, 'Unknown', NULL, a.ems_ip_addr) ems_ip_addr,  
             a.admin_state,  
             nvl(r.access_ind, 0) access_ind 
        FROM actl73x0 a, RPT_FTTX_ELEMENT_ID r  
       WHERE r.eid (+) = a.eid  
     UNION  
     SELECT   b.eid, b.node_sid, b.sw_version,  
             DECODE (b.cfg_type, 'BLM1500', 'Ericsson 1500', 'Ericsson 1500') cfg_type,  
             b.ems_name,  
             DECODE (b.ems_ip_addr, 'Unknown', NULL, b.ems_ip_addr) ems_ip_addr,  
             b.admin_state, 6 access_ind  
        FROM blm b  

     UNION  
     SELECT   b.eid, b.node_sid, b.sw_version,  
             DECODE (b.cfg_type, 'TA5000-CO', 'TA5006-HDT', 'TA5004-HDT') cfg_type,  
             b.ems_name,  
             DECODE (b.ems_ip_addr, 'Unknown', NULL, b.ems_ip_addr) ems_ip_addr,  
             b.admin_state, 
             DECODE (b.cfg_type, 'TA5000-CO', '12', 'TA5006-HDT', '14', 'TA5004-HDT', '13') access_ind    
        FROM ecil_ta500x b  
     UNION  
     SELECT   e.eid, e.node_sid, e.sw_version,  
             DECODE (e.cfg_type, 'EDA1200', 'EDA 1200', 'EDA 1200') cfg_type,  
             e.ems_name,  
             DECODE (e.ems_ip_addr, 'Unknown', NULL, e.ems_ip_addr) ems_ip_addr,  
              NULL admin_state, 
              nvl(r.access_ind, 0) access_ind 
        FROM eda e, RPT_FTTX_ELEMENT_ID r  
       WHERE r.eid (+) = e.eid  
     ORDER BY 1  ;
Was it helpful?

Solution

ORA-01790 for union statements means, that all corresponding columns of your unions have to have the same column type:

select a from taba
union
select b from tabb

Here a and b have to be of the same type.

In all of your subselects you have a access_ind column of type number except the one using your decode:

DECODE (b.cfg_type, 'TA5000-CO', '12', 'TA5006-HDT', '14', 'TA5004-HDT', '13') access_ind

Here a varchar value is returned. So that is causing the error. Change this line to

DECODE (b.cfg_type, 'TA5000-CO', 12, 'TA5006-HDT', 14, 'TA5004-HDT', 13) access_ind

and it should work. Here I use 12 instead of '12' and so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top