简体   繁体   中英

ORA-01427: SELECT * FROM TABLE gives error single-row subquery returns more than one row

I tried using the following variants:

SELECT * FROM "DB"."TABLE"
SELECT COUNT(1) FROM "DB"."TABLE"
SELECT reference FROM "DB"."TABLE"
SELECT reference FROM "DB"."TABLE" WHERE rownum < 2

where reference was a specific field of type cx_Oracle.STRING

All of those return the following error:

cx_Oracle.DatabaseError: ORA-01427: single-row subquery returns more than one row

I don't see why the final example would return an error complaining about returning more than one row, nor why returning more than one row would be a problem here in any of the examples.

I've seen a lot of similar problems on SO, but they all have nested selects where I can understand this being problematic, but these should just be simple selects.

The database is Oracle 11g Enterprise Edition, and it is being accessed through the cx_Oracle python interface.

It turns out the 'table' I was pulling from was in fact a database view, a sort of pseudo-table, which is composed of sql joining together other tables.

The error actually lay in the view, rather than in my SQL, which is where the subquery referred to in the error was. Thanks for the help in the comments!

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