Board index » delphi » Error: "Mult records found, but only one was expected"

Error: "Mult records found, but only one was expected"

I'm looping/reading through a text file and adding records to SQL tables as
I go.  I get the error message: "Mult records found, but only one was
expected".  This happens multiple times.  I've fixed one by skipping the
record and moving on (obviously, not the most ideal solution).  I fixed
another by truncating the variable assigned to a field to the field length
(this should happen automatically?).  The error message occurs during the
post as in the following sample:
Query1.Insert;
Query1Description.AsString := sDesc;
Query1.Post;
The SQL table behind it is really just that simple.  It has 2 fields(KEY
and DESCRIPTION).  KEY as autoincremented in the database.  As I mentioned
before, if sDesc is longer than the width of the DESCRIPTION field, I get
the error.  I fixed that and now the error occurs later.
I'm using:
Delphi5 Pro
MS-SQL 6.5

This is a real hair-puller for me.

Thanks
Greg

 

Re:Error: "Mult records found, but only one was expected"


Check your indexes. This happens when you have a non-unique index with
duplicate data...

Juan (TeamB)

Quote
"Greg Washburn" wrote:

> I'm looping/reading through a text file and adding records to SQL tables as
> I go.  I get the error message: "Mult records found, but only one was
> expected".  This happens multiple times.  I've fixed one by skipping the
> record and moving on (obviously, not the most ideal solution).  I fixed
> another by truncating the variable assigned to a field to the field length
> (this should happen automatically?).  The error message occurs during the
> post as in the following sample:
> Query1.Insert;
> Query1Description.AsString := sDesc;
> Query1.Post;
> The SQL table behind it is really just that simple.  It has 2 fields(KEY
> and DESCRIPTION).  KEY as autoincremented in the database.  As I mentioned
> before, if sDesc is longer than the width of the DESCRIPTION field, I get
> the error.  I fixed that and now the error occurs later.
> I'm using:
> Delphi5 Pro
> MS-SQL 6.5

> This is a real hair-puller for me.

> Thanks
> Greg

Re:Error: "Mult records found, but only one was expected"


Re:Error: "Mult records found, but only one was expected"


I'm guessing that you meant to say: a unique index with duplicate data?

I checked it out, there are no unique indexes or even unique fields on this
table.  But I tested your theory and I found that if I changed the value
being assigned to the field, I don't get the error message.  So I think I'm
getting closer.  After examining the data in the table, I find this value
in the field 148 times though.  Why does it not like the 149th time?  This
makes no sense, but I can reproduce it consistently.  The truly bizarre
aspect of this is that when I change the value for the row that causes the
error, rows after it with the same value do not cause the error.

Is it possible that it's another table causing the error, but it not being
reporting until posting to the table in question?  Would this qualify to
Borland as a BDE bug?  

I've brought Delphi into our organization (Michigan National Bank) after
much arm-twisting.  This is the first project we are doing with and the
future use of Delphi depends on how smoothly this project goes.  So far
I've spent a week on this bug with no success.  I really hope I can get
this figured out or it's back to VB and Access or us <shoot me>.

Thanks
Greg

Re:Error: "Mult records found, but only one was expected"


    Dont give up on Delphi yet. It's a fantastic product. Try transfering
the data from the text file to your SQL Server using the Import Export Data
(dtswiz.exe in MS SQL Server 7). If it reports errors, then the SQL Database
itself is throwing the error and not delphi.

    HTH,

Sunil Furtado
New Mangalore Port Trust

Quote
<Greg Washburn> wrote in message news:01c0218a$ce21d0e0$920716ac@washbug...
> I'm guessing that you meant to say: a unique index with duplicate data?

> I checked it out, there are no unique indexes or even unique fields on
this
> table.  But I tested your theory and I found that if I changed the value
> being assigned to the field, I don't get the error message.  So I think
I'm
> getting closer.  After examining the data in the table, I find this value
> in the field 148 times though.  Why does it not like the 149th time?  This
> makes no sense, but I can reproduce it consistently.  The truly bizarre
> aspect of this is that when I change the value for the row that causes the
> error, rows after it with the same value do not cause the error.

> Is it possible that it's another table causing the error, but it not being
> reporting until posting to the table in question?  Would this qualify to
> Borland as a BDE bug?

> I've brought Delphi into our organization (Michigan National Bank) after
> much arm-twisting.  This is the first project we are doing with and the
> future use of Delphi depends on how smoothly this project goes.  So far
> I've spent a week on this bug with no success.  I really hope I can get
> this figured out or it's back to VB and Access or us <shoot me>.

> Thanks
> Greg

Re:Error: "Mult records found, but only one was expected"


Quote
"Greg Washburn" wrote:

> I'm guessing that you meant to say: a unique index with duplicate data?

No, I meant a non-unique index with duplicate data.

If you bring up a result set in a query that has dup data and no unique
index and try to delete it, it will return this error message because it
tries to find a unique record to delete and can't. This doesn't happen
if you use a TTable but it's bad form to do that. Check your indexes.

Juan (TeamB)

Other Threads