简体   繁体   中英

How Can I fix Ora-01427 single-row subquery returns more than one row in select?

Am trying to run this query in Oracle in C# but getting

Exception: Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-01427: single-row subquery returns more than one row

select 
msisdn "Msisdn", 
first_name "OtherNames", 
last_name "Surname", 
gender "Gender", 
card_number "CardNumber", 
card_type_v "CardType", 
to_char(CARD_EXPIRY_DATE, 'yyyy-mm-dd hh24:mi:ss') "CardExpiryDate", 
to_char(REQUEST_DATE, 'yyyy-mm-dd hh24:mi:ss') "Identifier", 
to_char(DATE_OF_BIRTH_D, 'yyyy-mm-dd hh24:mi:ss') "DateOfBirth", 
address "Address" 
from NIA_MOMO_DETAILS 
where REQUEST_DATE > to_timestamp('2022-10-07 13:10:29', 'yyyy-mm-dd hh24:mi:ss') AND ROWNUM < 500 ORDER BY REQUEST_DATE ASC

But the query runs fine when executed directly on oracle

After several hours searching for solution, I Just updated this with to_timestamp('2022-10-07 13:10:29', 'yyyy-mm-dd hh24:mi:ss') with trunc and the issue was solved.

trunc(to_timestamp('2022-10-07 13:10:29', 'yyyy-mm-dd hh24:mi:ss'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM