VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: mailblade on May 05, 2020, 08:47:04 AM

Title: SQL Query not working after using it for 3 years without issues, [solved]
Post by: mailblade on May 05, 2020, 08:47:04 AM
I've been running the below piece of code in an event scheduler for the past 3 years without any issue.

UPDATE `jos_virtuemart_product_customfields` SET `customfield_value`= `customfield_value` - 1 WHERE `virtuemart_custom_id` = 22 AND `customfield_value` !="0"

However, since yesterday, I have been getting the following error:

Quote#1292 - Truncated incorrect DOUBLE value: ''

I haven't changed anything in my Virtuemart DB or done anything remotely different. Has anyone experienced this before ?
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: AH on May 05, 2020, 09:35:22 AM
Tested here and seems to work fine
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: Jörgen on May 05, 2020, 09:58:05 AM
Some googling

QuoteThis message means you're trying to compare a number and a string in a WHERE clause; either make sure they have similar declarations, or use an explicit CAST to convert the number to a string. If you turn off strict mode, the error should turn into a warning.Jun 30, 2016

Jörgen @ Kreativ Fotografi
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: mailblade on May 06, 2020, 08:22:32 AM
@AH thank you, glad it is still working. Must be something wrong on my end then.

@Jorgen: I also found the above page, thanks for providing the quotes. I will try fixing it.

Title: Re: SQL Query not working after using it for 3 years without issues
Post by: Jörgen on May 06, 2020, 08:42:28 AM
Tell us how it goes.

Jörgen @ Kreativ Fotografi
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: mailblade on May 06, 2020, 08:47:33 AM
@Jurgen: I just ran it again and all seems back to normal. That was pretty weird  :D

I did re-upload all the customfield_values where virtuemart_custom_id = 22 yesterday afternoon, so maybe that helped to sort it out.
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: Jörgen on May 06, 2020, 09:55:47 AM
Nice to hear that it works again, pity that the cause remains some what unknown.

Jörgen @ Kreativ Fotografi
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: mailblade on May 09, 2020, 08:26:13 AM
I found the reason why it was not working!

There was one null value in the customfield_values where virtuemart_custom_id = 22, so it was impossible to minus this value by "1".  This is why I got the error!
Title: Re: SQL Query not working after using it for 3 years without issues
Post by: AH on May 09, 2020, 11:28:16 AM
Great - thanks for the update