dbTalk Databases Forums  

Bad insert

comp.databases.mysql comp.databases.mysql


Discuss Bad insert in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bint
 
Posts: n/a

Default Bad insert - 02-25-2011 , 10:11 AM






Hello,

I had an incorrect script, which attempted to INSERT a row with the
incorrect number of values. I got back a "bad insert" error. I've since
changed the script to reference the fields by name.

However, that one record I inserted is like a ghost now. I don't see it if
I browse the database with phpMyAdmin. My regular scripts don't report it
as being part of the database. But if I attempt to save a new record with
the same name, it says it already exists.

I am kind of new with mySql. Is there any way to delete this phantom record
or on the other hand get it to show up fully?

Thanks
B

Reply With Quote
  #2  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 10:21 AM






Bint:

Quote:
However, that one record I inserted is like a ghost now. I don't
see it if I browse the database with phpMyAdmin. My regular scripts
don't report it as being part of the database. But if I attempt to
save a new record with the same name, it says it already exists.
Sounds like it's indexed, but there are no data.
What does "a new record with the same name" mean?


--
Erick

Reply With Quote
  #3  
Old   
Bint
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 12:45 PM



On 2/25/11 10:21 AM, in article 8sq37hFlc9U1 (AT) mid (DOT) individual.net, "Erick T.
Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
Bint:

However, that one record I inserted is like a ghost now. I don't
see it if I browse the database with phpMyAdmin. My regular scripts
don't report it as being part of the database. But if I attempt to
save a new record with the same name, it says it already exists.

Sounds like it's indexed, but there are no data.
What does "a new record with the same name" mean?

It means I am able to do an UPDATE call to the record, using the filename,
and it says it is OK. But it still doesn't show up in the database when I
do SELECT or just browse with phpMyAdmin.

B

Reply With Quote
  #4  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 01:25 PM



Bint:

Quote:
On 2/25/11 10:21 AM, in article 8sq37hFlc9U1 (AT) mid (DOT) individual.net,
"Erick T. Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Bint:

However, that one record I inserted is like a ghost now. I
don't see it if I browse the database with phpMyAdmin. My
regular scripts don't report it as being part of the database.
But if I attempt to save a new record with the same name, it
says it already exists.

Sounds like it's indexed, but there are no data.
What does "a new record with the same name" mean?


It means I am able to do an UPDATE call to the record, using the
filename, and it says it is OK.
That still leaves me puzzled. What filename?
Anyway, could you plase compare the number of rows in the table with
the number of entries in the index of the primary key (using
phpMyAdmin)?


--
Erick

Reply With Quote
  #5  
Old   
Bint
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 02:34 PM



On 2/25/11 1:25 PM, in article 8sqe16FvfmU1 (AT) mid (DOT) individual.net, "Erick T.
Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
Bint:


On 2/25/11 10:21 AM, in article 8sq37hFlc9U1 (AT) mid (DOT) individual.net,
"Erick T. Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Bint:

However, that one record I inserted is like a ghost now. I
don't see it if I browse the database with phpMyAdmin. My
regular scripts don't report it as being part of the database.
But if I attempt to save a new record with the same name, it
says it already exists.

Sounds like it's indexed, but there are no data.
What does "a new record with the same name" mean?


It means I am able to do an UPDATE call to the record, using the
filename, and it says it is OK.

That still leaves me puzzled. What filename?
Anyway, could you plase compare the number of rows in the table with
the number of entries in the index of the primary key (using
phpMyAdmin)?

Sorry. The filename is just one of the fields in this table, which is
'files'. So I think of each of the records as a file.

The table looks like it has 683 rows. I think that the number of entries in
the index is also 683. At least that is what it says under "Cardinality"
under Indexes for the primary key.

Thanks
B

Reply With Quote
  #6  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 02:53 PM



Bint:

Quote:
The table looks like it has 683 rows. I think that the number of
entries in the index is also 683. At least that is what it says
under "Cardinality" under Indexes for the primary key.
You could consider building up the table from scratch:
0. Shut down the application
1. Make a backup of the table
2. Check your backup. Make sure it is OK.
3. Delete (or better yet: rename) your table
4. Restore the original table from the backup file
5. See what happens now.

--
Erick

Reply With Quote
  #7  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: Bad insert - 02-25-2011 , 03:59 PM



Bint wrote:
Quote:
On 2/25/11 10:21 AM, in article 8sq37hFlc9U1 (AT) mid (DOT) individual.net, "Erick T.
Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Bint:

However, that one record I inserted is like a ghost now. I don't
see it if I browse the database with phpMyAdmin. My regular scripts
don't report it as being part of the database. But if I attempt to
save a new record with the same name, it says it already exists.
Sounds like it's indexed, but there are no data.
What does "a new record with the same name" mean?


It means I am able to do an UPDATE call to the record, using the filename,
and it says it is OK. But it still doesn't show up in the database when I
do SELECT or just browse with phpMyAdmin.

B

If you can identify the record, you can try a "delete ....where..." to
remove it...

Reply With Quote
  #8  
Old   
Brian Cryer
 
Posts: n/a

Default Re: Bad insert - 03-01-2011 , 04:21 AM



"Bint" <bint (AT) ign (DOT) com> wrote

Quote:
Hello,

I had an incorrect script, which attempted to INSERT a row with the
incorrect number of values. I got back a "bad insert" error. I've since
changed the script to reference the fields by name.

However, that one record I inserted is like a ghost now. I don't see it
if
I browse the database with phpMyAdmin. My regular scripts don't report it
as being part of the database. But if I attempt to save a new record with
the same name, it says it already exists.

I am kind of new with mySql. Is there any way to delete this phantom
record
or on the other hand get it to show up fully?
There is no phantom record. If the insert failed then it didn't insert any
records. That said, if you did a number of inserts in a script and one
failed, then it will have inserted the ones before but not the one which
failed or the ones after. So you may have inserted some records.

It sounds more likely that you have some unique indexes and when you are
trying to do an insert that the record you are trying to insert has a values
which break one or more unique constraints.

So:
1. What is the actual error which comes back when you try to insert.
2. How many unique indexes do you have on that table - and have you checked
each one to make sure that the new record is genuinly unique. It may not be
the "name" field which is causing the problem.
--
Brian Cryer
http://www.cryer.co.uk/brian

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.