[erlang-questions] Parametrized queries in mysql-otp
Tue Jun 9 13:50:51 CEST 2015
ok = mysql_poolboy:query(?DB_POOL_NAME,
"INSERT INTO `X` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, 1, 0, ?)
ON DUPLICATE KEY
UPDATE c = c + 1, d = 0, e = ?",
[A, B, C, C]);
On Tue, Jun 9, 2015 at 11:42 AM, Fabio Souto <Fabio.Souto@REDACTED>
> Hello fellows,
> I’m implementing a project that uses mysql-otp for some of its components.
> At one point, I have to do an INSERT statement with an ON DUPLICATE KEY
> 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.
> I can’t find a way to name parameters in the parametrized query. Was
> wondering if anyone had similar experience before.
> Below follows a generic example of what I’m trying to achieve.
> ok = mysql_poolboy:query(?DB_POOL_NAME,
> "INSERT INTO `X` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, 1, 0, ?)
> ON DUPLICATE KEY
> UPDATE c = c + 1, d = 0, e = ?",
> [A, B, C]);
> 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.
> *Fábio S.*
> *Team Rocket*
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions