in reply to DBD and a MySQL query with a SET @num line

From the DBI documentation http://search.cpan.org/~timb/DBI-1.630/DBI.pm#General_Interface_Rules_&_Caveats: Multiple SQL statements may not be combined in a single statement handle ($sth), although some databases and drivers do support this (notably Sybase and SQL Server).
However, you can do it sequentially:
$dbh->do('SET \@num := 0, \@id := -1;'); my $ar_results = $dbh->selectall_arrayref( qq( QUERY GOES HERE ), { Sl +ice => {} });

Replies are listed 'Best First'.
Re^2: DBD and a MySQL query with a SET @num line
by edieguez (Initiate) on Jan 22, 2014 at 04:10 UTC
    Thank you. I missed that section of the DBI documentation (i.e., I should have read the caveats). Now I understand why I can break the query into two sequential executions and see it work but fail when its combined into a single code.sql file.