Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: DBD and a MySQL query with a SET @num line

by Neighbour (Friar)
on Jan 20, 2014 at 10:19 UTC ( [id://1071291]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071291]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found