[Zope] Error, _mysql_exceptions. 'ON DUPLICATE KEY

Wayne Connolly Wayne Connolly" <wayne@c-media.com.au
Tue, 1 Jul 2003 00:18:00 +1000


This is a multi-part message in MIME format.

------=_NextPart_000_0040_01C33F66.3AC26BA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, i have been playing round with this insert/update script on =
zope/mysql and keep recieving the following error...any idea's on how to =
get rid of this would be muchly appreciated?

--------------------------------------------------------------------
Error, _mysql_exceptions.ProgrammingError: (1064, "You have an error in =
your SQL syntax near 'ON DUPLICATE KEY update charts set \n =
plays=3Dplays + 1\n\twhere title=3D'wayne'' at line 14")=20
--------------------------------------------------------------------

the ZSQL used is below

--------------------------------------------------------------------
insert into charts
 (title,
 artist,
 genre,
 album,
 plays)
 VALUES (<!--#sqlvar title type=3Dstring --> ,
  <!--#sqlvar artist type=3Dstring --> ,
  <!--#sqlvar genre type=3Dstring --> ,
  <!--#sqlvar album type=3Dstring --> ,
  plays=3D1
  )

ON DUPLICATE KEY

update charts set=20
        plays=3Dplays + 1
 where title=3D<dtml-sqlvar title type=3Dnb> and artist=3D<dtml-sqlvar =
artist type=3Dnb>

------=_NextPart_000_0040_01C33F66.3AC26BA0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, i have been playing round with this =

insert/update script on zope/mysql and keep recieving the following =
error...any=20
idea's on how to get rid of this would be muchly =
appreciated?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV>
<DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----</FONT></DIV></FONT></DIV>
<DIV><STRONG>Error, =
<EM>_mysql_exceptions.ProgrammingError</EM>:</STRONG> (1064,=20
"You have an error in your SQL syntax near 'ON DUPLICATE KEY update =
charts set=20
\n plays=3Dplays + 1\n\twhere title=3D'wayne'' at line 14") </DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the ZSQL used is below</FONT></DIV>
<DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----</FONT></DIV></DIV>
<DIV><FONT face=3DArial size=3D2>insert into=20
charts<BR>&nbsp;(title,<BR>&nbsp;artist,<BR>&nbsp;genre,<BR>&nbsp;album,<=
BR>&nbsp;plays)<BR>&nbsp;VALUES=20
(&lt;!--#sqlvar title type=3Dstring --&gt; =
,<BR>&nbsp;&nbsp;&lt;!--#sqlvar artist=20
type=3Dstring --&gt; ,<BR>&nbsp;&nbsp;&lt;!--#sqlvar genre type=3Dstring =
--&gt;=20
,<BR>&nbsp;&nbsp;&lt;!--#sqlvar album type=3Dstring --&gt;=20
,<BR>&nbsp;&nbsp;plays=3D1<BR>&nbsp;&nbsp;)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>ON DUPLICATE KEY</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>update charts set=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plays=3Dplays + =
1<BR>&nbsp;where=20
title=3D&lt;dtml-sqlvar title type=3Dnb&gt; and artist=3D&lt;dtml-sqlvar =
artist=20
type=3Dnb&gt;</FONT></DIV></BODY></HTML>

------=_NextPart_000_0040_01C33F66.3AC26BA0--