DelphiFAQ Home Search:

SQL error message 'Multiple rows in a singleton select'

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Question:

I need to know how to resolve an exception that says 'Multiple rows in a singleton select'

Answer:

This error message happens when you have a select statement (in a stored procedure) that you expected to return one row but (because of erronous data?) it returns multiple rows.

E.g.
select customer_name
from customers
where cust_id = 1234
into :c_name;


This works fine until you have two records with cust_id = 1234.
If you are in a situation like me (a project with 150 stored procedures totalling 40,000 lines of brainless SQL) then this may be hard to find. Once you know which stored procedure, you can try changing your statements by putting them temporarily into FOR loops:

for
  select customer_name
  from customers 
  where cust_id = 1234
  into :c_name
  do begin
    some_dummy_statement; /* maybe log here? */
  end;

Comments:

2008-10-02, 22:14:10
anonymous from Philippines  
when was this posted....?

anyway, i have a question too...

i have this simple statement:

SELECT * FROM FirstTable;

why is it when i execute it still got the error
Multiple rows in a singleton select


weird.......................... it's the simplest statement (i guess) in sql and i got an error?!?!? really weird...

(--,)
2015-02-01, 12:19:30
anonymous  
Super jazzed about getting that knowoh-w.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: