Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(dkubb) Re: (2) Deleting Multiple MySQL Rows With DBI

by dkubb (Deacon)
on May 24, 2001 at 05:35 UTC ( #82790=note: print w/replies, xml ) Need Help??


in reply to Deleting Multiple MySQL Rows With DBI

Remember, you only need to prepare a statement handle if you are going to re-use it for more than 1 query. Otherwise, you can use the Database Handle Methods for one-time queries. They encapsulate a prepare, execute, and sometimes a fetch-type method in a single call. For INSERT or UPDATE statements use DBI::do.

The following statement does a batch DELETE without using any 'Synthetic' Code, and is tested to work with MySQL:

$dbh->do( sprintf( 'DELETE FROM table WHERE message_id IN(%s)', join ',', ('?') x @MESSAGE_IDS ), {}, @MESSAGE_IDS, );

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-12-10 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?