Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: Perl DBI not storing @prev_value in query

by poj (Abbot)
on Jan 25, 2018 at 18:55 UTC ( [id://1207916] : note . print w/replies, xml ) Need Help??

in reply to Re^2: Perl DBI not storing @prev_value in query
in thread Perl DBI not storing @prev_value in query

I'm not sure exactly why it works

It works because the user defined variables need to be initialized. Because variables are session specific they are 'retained' when using MySQL workbench. You should notice that your original query does not work in MySQL workbench on the first run but then works on subsequent runs. Using DBD you are creating a new session each time so variables never get initialized. You could use your original query by adding a set command before the execute

$dbh->do('SET @recent_post_rank := 0, @prev_discussion := 0');