sql - ORA-01427: single-row subquery returns more than one row- multiple values needed -
i have following sql query on oracle
select case when (select distinct(trim(z.m_base_acct)) acc_mapping_rep z z.m_dyn_acct=b.m_en_credit , z.m_ref_data =b.m_ref_data) in 'samanos' '7200000888001x' end m_en_crdr acc_journal_rep b , b.m_ref_data = 41091 , b.m_en_date = '21-sep-15' , b.m_entity = 'ln' , b.m_nb_trn = 0 i having oracle error ora-01427. due line have case when condition knowing did put in operator instead of equal. please advise. need have multiple values in case condition.
if you've shown have 1 value compare, 'samanos', can swap terms:
select case when 'samanos' in (select distinct(trim(z.m_base_acct)) acc_mapping_rep z z.m_dyn_acct=b.m_en_credit , z.m_ref_data =b.m_ref_data) '7200000888001x' end m_en_crdr ... you left-join acc_mapping_rep table, distinct , trim worrying - if needed becomes little more complicated , you'd need left-join inline view of table.
the b.m_en_date = '21-sep-15' worrying; if m_en_date date column you're relying on implicit conversions , session nls settings. better use to_date(), or fixed value date literal: b.m_en_date = date '2015-09-21'.
your original longer code benefit using ansi joins instead of old oracle-specific (+) outer join operator.
Comments
Post a Comment