I'm running a query like this:
INSERT INTO `ABC` (
`col1`,
`col2`)
SELECT
`t`.`col1`,
`t`.`col2`
FROM (
SELECT
`opr`.`col1`,
@counter := IF(@var_2 = `opr`.`col_2`, @counter + 1, 1) AS `counter`,
@val_2 := `opr`.`col2`
FROM
(...Some select ...) `opr`
) t
Running this query in SequelPro (SQL editor) works perfect. However, when running this using org.skife.jdbi (as an @SqlUpdate), the user-defined variable @counter is always 1, producing the wrong update.
Moreover, I've tried warpping up this update query into a Stored Procedure: - When I call the SP from SequelPro, I get the correct results. - When I call the SP from JDBI, I get wrong results (@counter == 1).
The SQL query Java is executing is correct (I've looked my MySQL log to check what Java is executing), however is failing to evaluate correctly my user-defined variables, wether I call an explicit query or if I call a SP containing my query.
Ideas? Is this a bug of JDBC or org.skife.jdbi?