<div dir="ltr"><div>ok = mysql_poolboy:query(?DB_POOL_NAME, </div><div><span class="" style="white-space:pre"> </span>"INSERT INTO `X` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, 1, 0, ?) </div><div><span class="" style="white-space:pre"> </span> ON DUPLICATE KEY </div><div><span class="" style="white-space:pre"> </span> UPDATE c = c + 1, d = 0, e = ?", </div><div><span class="" style="white-space:pre"> </span>[A, B, C, C]);</div><div><br></div><div>Doesn't work?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 9, 2015 at 11:42 AM, Fabio Souto <span dir="ltr"><<a href="mailto:Fabio.Souto@miniclip.com" target="_blank">Fabio.Souto@miniclip.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif"><div>Hello fellows,</div><div><br></div><div>I’m implementing a project that uses mysql-otp for some of its components.</div><div>At one point, I have to do an INSERT statement with an ON DUPLICATE KEY clause.</div><div>What happens is that on the ON DUPLICATE KEY statement, I only want to use the last parameter of the parameter list I provide in the query() call.</div><div>I can’t find a way to name parameters in the parametrized query. Was wondering if anyone had similar experience before.</div><div><br></div><div>Below follows a generic example of what I’m trying to achieve.</div><div><br></div><div><div><span style="white-space:pre-wrap"> </span>ok = mysql_poolboy:query(?DB_POOL_NAME, </div><div><span style="white-space:pre-wrap"> </span>"INSERT INTO `X` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, 1, 0, ?) </div><div><span style="white-space:pre-wrap"> </span> ON DUPLICATE KEY </div><div><span style="white-space:pre-wrap"> </span> UPDATE c = c + 1, d = 0, e = ?", </div><div><span style="white-space:pre-wrap"> </span>[A, B, C]);</div></div><div><br></div><div>I want e = C, in the duplicate key statement. Right now, as it is, I’m not sure of what the behaviour will be, but e will probably be e = A.</div><div><br></div><div>Cheers,</div><span class="HOEnZb"><font color="#888888"><div><div><div style="color:rgb(0,0,0)">-- </div><div><p style="color:rgb(34,34,34);background-color:rgb(255,255,255);margin:0cm 0cm 0.0001pt;font-size:11pt"><font color="#1f497d"><b>Fábio S.</b></font></p><p style="color:rgb(34,34,34);background-color:rgb(255,255,255);margin:0cm 0cm 0.0001pt;font-size:11pt"><font color="#1f497d"><b>Team Rocket</b></font></p></div></div></div></font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>