Forums / Upgrading from 1.3.x to 1.3.9 / 1062 Duplicate entry 'Customers who have never...

1062 Duplicate entry 'Customers who have never...

Locked

Started by lostsheep on 15 Dec 2007, 4:12 AM · Views: 9,744

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
15 Dec 2007, 4:12 AM
#1
lostsheep avatar

lostsheep

Inactive

Join Date:
Aug 2006
Location:
ulaanbaatar
Posts:
94
Plugin Contributions:
0

1062 Duplicate entry 'Customers who have never...

I'm trying to upgrade to 1.3.8a and when I click database upgrade I got the following message:

1062 Duplicate entry 'Customers who have never completed a purchase' for key 2
in:
[INSERT INTO query_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');]

As I guess the matter was in (.) in between 'c' and 'LEFT'. Is it right (means bug) ?
If so where it can be changed?
If not what should I do next?
Thank you

save nature = save water

15 Dec 2007, 4:16 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

LostSheep:

As I guess the matter was in (.) in between 'c' and 'LEFT'. Is it right (means bug) ?No, it's not a bug.
It's trying to insert a record that apparently already exists.
Did you run the database upgrade twice for some reason?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

15 Dec 2007, 4:18 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

Run this using the SQL Patch tool in the Admin->Tools menu:```
DELETE from query_builder where query_name = 'Customers who have never completed a purchase';

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

30 Dec 2007, 1:11 AM
#4
golowenow avatar

golowenow

New Zenner

Join Date:
Jul 2006
Location:
Washington State
Posts:
78
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

Hello Dr. Byte,
Well this did not work for me. I am using MySQL 5.0.45. I tried this option several times and still when running the upgrade it would stop at the query_builder commands.:huh: I ran the upgrade several times using the original database, and then deleted the original database and recreated it from backup and tried again with no luck. First run came up with the error. This is upgrading 1.3.7 to 1.3.8a.
I ended up running the upgrade SQL file manually. I took each section of upgrade commands and ran them on the database separately. All went well until I got to the set of Query_builder commands and once again I got errors. This was on a freshly rebuilt database.
What I did next is I opened up the install.sql file that came with 1.3.8a and ran a name search on it which took me to the query_builder commands. I ran the first set which deleted if it existed and then builds the query_builder tables. There were no errors.:smartalec:
Running the name search again took me down to the commands that I guess adds the data to the Query_builder tables which is quite a few commands. I ran those next and had no errors.:smartalec:
Then I went back into the upgrade sql file and separately ran each group of commands after the query_builder group. Meaning I ignored and did not use the query_builder commands in the upgrade file. All the rest of the upgrade groups went in with no problems. My carts are running perfectly as far as I can tell and the versions are at 1.3.8a.
The question is that this problem may be with the latest MySQL database. I am running PHP 5.2.4 also so this may have issue. Everything is STRICT mode.
Hopefully this will help others.
Please do not use this method unless all else fails including getting expert help if needed. I am a risky player with code...hehe:frusty:

1 Jan 2008, 3:38 PM
#5
sodajim avatar

sodajim

New Zenner

Join Date:
May 2005
Posts:
93
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

Thanks DrByte for this little tip as I inadvertantly downgraded my DB Patch to 1.3.7 and couldn't get the db upgrade to allow 1.3.7 -> 1.3.8a...
After the SQL execution, re-run the upgrade and all is well ! ! !

Many Thanks again !
Jim

5 Jan 2008, 8:48 PM
#6
travel124 avatar

travel124

Zen Follower

Join Date:
Mar 2006
Location:
White Pigeon, MI
Posts:
160
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

I keep getting this error too. I have gone to my admin and entered: SQL Query delete portion and I have even done a fresh install of my database but no luck!

I have been workin on this for 2 days now and very very frustrated at this point.

1062 Duplicate entry 'Customers who have never completed a purchase' for key 2
in:
[INSERT INTO zen_query_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');]

5 Jan 2008, 8:53 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

travel124:

I keep getting this error too. I have gone to my admin and entered: SQL Query delete portion and I have even done a fresh install of my database but no luck! Then maybe you're hitting the wrong database or table?

travel124:

[INSERT INTO** zen_query_builder** ...
If you've deleted the entry, but it keeps saying it exists, then you're probably not deleting it from the right place.

The upgrader will only attempt to run that INSERT command when you do the 1.3.7-to-1.3.8 upgrade step.
If you've already done that step once, then naturally it would be expected that it would croak.
If you are certain you've done everything correctly and don't care about that particular statement, edit the /zc_install/sql/mysql_zencart_upgrade_137_to_138.sql file and put a # at the beginning of that line to comment it out.
Then cross your fingers when you run that upgrade step again.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Jan 2008, 9:39 PM
#8
travel124 avatar

travel124

Zen Follower

Join Date:
Mar 2006
Location:
White Pigeon, MI
Posts:
160
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

I am fine now.

Thanks for your help!

New issue with admin here: http://www.zen-cart.com/forum/showthread.php?t=84655

15 Apr 2008, 11:01 PM
#9
dollen avatar

dollen

New Zenner

Join Date:
Apr 2008
Location:
Arvada, CO
Posts:
21
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

I really do try not to tag on to threads with such good documentation.. but I can't make it work. I keep trying what I find here on he boards but to no resolve. So with my deepest apologies can someone please have a look at my work and help me find some more things to try.

The problems I am having.
Can't Log in to my cart
1062 Dup error.. can't upgrade cart to 1.38a

Info:
https://store.angeleyes.org/

I am trying to upgrade from 1.3.8 to 1.3.8a to fix the "can't log in to my cart problem.
Error code:
Error There was a security error when trying to login.

Error code:
1062 Duplicate entry 'Customers who have never completed a purchase' for key 2
in:
[INSERT INTO zenquery_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');]

Any help is very appreciated.. DrByte, looks like you help more people that Red Cross does.. once I get this thing working you get a Gift Certificate in appreciation. Dubious prize I know, but its just a token of appreciation.

Cam
Rj Dollen

Current ZC efforts
store.angeleyes.org
store.dollen.com/2

16 Apr 2008, 3:00 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

Another approach you can try is to add a # before the INSERT statement mentioned ... which will cause it not to be processed.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Apr 2008, 3:25 AM
#11
dollen avatar

dollen

New Zenner

Join Date:
Apr 2008
Location:
Arvada, CO
Posts:
21
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

DrByte:

Another approach you can try is to add a # before the INSERT statement mentioned ... which will cause it not to be processed.

I am shamed a little here to say.. I have no idea what to do with that chuck of code.. the "[INSERT INTO zen_query_builder (...." bit is a mystery to me.

So "#[INSERT INTO zen_query_builder (...." goes where?

Cam

Current ZC efforts
store.angeleyes.org
store.dollen.com/2

16 Apr 2008, 4:47 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

Try my first message in this related thread: http://www.zen-cart.com/forum/showthread.php?t=94097

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Apr 2008, 5:18 AM
#13
dollen avatar

dollen

New Zenner

Join Date:
Apr 2008
Location:
Arvada, CO
Posts:
21
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

I wish I could report great success here. Its just not working and the best I can tell.. it should be. :frusty: Tell me this DrByte... are you for hire?

I am starting to think that restoring an older version of the database and redoing some work might be easier. I do still have a payment module to drop into this if I can ever get it working.

Current ZC efforts
store.angeleyes.org
store.dollen.com/2

16 Apr 2008, 5:25 AM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

You did do full backups before upgrading, right?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Apr 2008, 5:30 AM
#15
dollen avatar

dollen

New Zenner

Join Date:
Apr 2008
Location:
Arvada, CO
Posts:
21
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

I use Dreamhost and they do it every 12 hours or so. I am pretty sure I can restore. Not positive. But I think so. I know I am dangerous with my limited knowledge here but here is the plan in my head:

Restore the DB
Copy all the files from the server (Zen Cart Files) that I used before the upgrades
See how far back I am with my products, customizations and such.
Once I have it all working again I have a Payment module to dump in from Transfirst.com

That and a Fat Tire (beer)

Cam

Current ZC efforts
store.angeleyes.org
store.dollen.com/2

16 Apr 2008, 3:56 PM
#16
dollen avatar

dollen

New Zenner

Join Date:
Apr 2008
Location:
Arvada, CO
Posts:
21
Plugin Contributions:
0

Re: 1062 Duplicate entry 'Customers who have never...

Hi,
So with a clearer mind and a rejuvenated will I am back. Here is the current state of my cart:
My problems started after I ran the 1.3.8a update.
I installed my Transfirst.com merchant model (just released for 1.3.8a)
Then when I went to test it I could not log-in. I was getting a Security error. Something to the similar to "There was a security Error" in a red box above the log-in fields.
I ran this "DELETE from query_builder where query_name = 'Customers who have never completed a purchase';" so that I could re-run the install.
Ran the install with this error:
"1062 Duplicate entry 'Customers who have never completed a purchase' for key 2
in:
[INSERT INTO zenquery_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');]"

Then I put a # in front of the "INSERT INTO " in the /zc_install/sql/mysql_upgrade_137_to_138.sql file

which brings me to where I am now:
I have backed up the files on my server both before and after the upgrade attempt.
My DB backs up automatically and can be restored in 12 hour chunks
I have debated restoring and copying the old files over, then trying a reinstall but don't know if that is a doable option or if I will mess stuff up doing it.

What I need to fix right now:
customers can not register for an account.. it just loops back to the same page with no errors.
Existing customers: me, can not login

Other notes that might be helpful:
This is not really live yet. There are not customers to save or data for them that I can not put back.
I would really like to keep all the products, attributes, customizations to the template and custom verbiage I have added.

Can anyone make sense of this predicament?

Thanks, Cam

Current ZC efforts
store.angeleyes.org
store.dollen.com/2

17 Apr 2008, 5:53 AM
#17
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: 1062 Duplicate entry 'Customers who have never...

dollen:

My problems started after I ran the 1.3.8a update.

If that "update" didn't include upgrading not only your database but also all your PHP files (both core and overrides), then you'll have various unexplainable problems ... curable only by properly completing both halves of the upgrade.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.