Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:20:20+00:00 2026-05-17T01:20:20+00:00

I’m getting the error [ORA-01427: single-row subquery returns more than one row] when I

  • 0

I’m getting the error [ORA-01427: single-row subquery returns more than one row] when I execute a query. I have a query structured like so:

SELECT LV.PRICE,
 (SELECT C.MODEL_NAME FROM CARS C WHERE C.MODEL_ID = LV.MODEL_ID) as MODEL_NAME
FROM LEDGER_VIEW LV
WHERE LV.PRICE < 500

It’s breaking on the nested select. I know the logic both in the view and in this query is correct, and that there’s no chance of the nested select returning more than one row. The CARS table’s MODEL_ID is a unique field. If I execute the query without the nested select it doesn’t return this error.

The LEDGER_VIEW is a view built on top of another view. Is it possible that these stacked views are buggy in Oracle 10g? I don’t know how else to debug this problem.

I am aware I could change this particular query to a join rather than a nested select, but I’d like to know why this is happening because I use nested queries in other places where it is not so easily modifiable.

EDIT: Here’s the really strange thing. The LEDGER_VIEW is, as I said, built on top of another view. As a test, I copied the nested view’s SQL directly into the SQL of the SQL of LEDGER_VIEW, in place of the nested view, and it returned with no errors (as expected). This seems to confirm to me that there is some buggy behavior either with nested views or with the combination of nested views + database links.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:20:20+00:00Added an answer on May 17, 2026 at 1:20 am

    I am unable to recreate via a creation of a stacked view. (althoug RedFilters will find the culprit)

        CREATE TABLE t1
        (
            t1_id NUMBER        ,
            txt   VARCHAR2( 50 ),
            CONSTRAINT t1_pk PRIMARY KEY( t1_id )
        ) ;
    
    
        CREATE TABLE t2
        (
            t2_id NUMBER                      ,
            t1_id NUMBER                      ,
            price NUMBER( 10, 4 )             ,
            CONSTRAINT t2_pk PRIMARY KEY( t2_id ),
            CONSTRAINT t2_fk FOREIGN KEY( t1_id ) REFERENCES t1( t1_id )
        );
    
        insert into t1(t1_id, txt) values(1,'fit');
        insert into t1(t1_id, txt) values(2,'focus');
        insert into t1(t1_id, txt) values(3,'golf');
        insert into t1(t1_id, txt) values(4,'explorer');
        insert into t1(t1_id, txt) values(5,'corolla');
    
    insert into t2(t2_id, t1_id, price) values(1,1,17000);
    insert into t2(t2_id, t1_id, price) values(2,2,16000);
    insert into t2(t2_id, t1_id, price) values(3,3,22000);
    insert into t2(t2_id, t1_id, price) values(4,4,31000);
    insert into t2(t2_id, t1_id, price) values(5,5,17000);
    
    
    create view t1_view as select * from t1;
    create view t2_view as select * from t2;
    create view t_stacked_view as 
      select t1_view.txt ,
           t2_view.price ,
             t1_view.t1_id
        from t1_view 
              left join
              t2_view 
                on t1_view.t1_id = t2_view .t1_id
        ;   
    
    
    --stacked view test
    select t1_view.txt ,
           (select t_stacked_view.price 
                from t_stacked_view 
                 where t1_view.t1_id = t_stacked_view .t1_id) price
        from t1_view ;
    
    --or better yet, just drop the row level query
    select t1_view.txt ,
           t2_view.price
        from t1_view 
              left join
              t2_view 
                on t1_view.t1_id = t2_view .t1_id
        ; 
    

    But that begs the question, why are you doing the row level query here? While 10g ought to optimize them the same, I have always found it easier to write queries as below, both for readability, maintainability, and to specifically avoid the error you are having (is it always, 3 years down the road, guaranteed by the application (both in the db and the calling app) that you cannot have a condition that will cause this error? One rouge statement gets in and your entire app dies?

        SELECT LV.PRICE,
                c.model_name
    FROM LEDGER_VIEW LV
          LEFT /* OR INNER */ JOIN CARS C 
           ON C.MODEL_ID = LV.MODEL_ID
    WHERE LV.PRICE < 500
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.