Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:14:14+00:00 2026-05-27T08:14:14+00:00

Has anyone seen a DBI-type module for Perl which capitalizes, easily, on MySQL’s multi-insert

  • 0

Has anyone seen a DBI-type module for Perl which capitalizes, easily, on MySQL’s multi-insert syntax

insert into TBL (col1, col2, col3) values (1,2,3),(4,5,6),...?

I’ve not yet found an interface which allows me to do that. The only thing I HAVE found is looping through my array. This method seems a lot less optimal vs throwing everything into a single line and letting MySQL handle it. I’ve not found any documentation out there IE google which sheds light on this short of rolling my own code to do it.

TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:14:15+00:00Added an answer on May 27, 2026 at 8:14 am

    There are two approaches. You can insert (?, ?, ?) a number of times based on the size of the array. The text manipulation would be something like:

    my $sql_values = join( ' ', ('(?, ?, ?)') x scalar(@array) );
    

    Then flatten the array for calling execute(). I would avoid this way because of the thorny string and array manipulation that needs to be done.

    The other way is to begin a transaction, then run a single insert statement multiple times.

    my $sql = 'INSERT INTO tbl (col1, col2, col3)';
    $dbh->{AutoCommit} = 0;
    my $sth = $dbh->prepare_cached( $sql );
    $sth->execute( @$_ ) for @array;
    $sth->finish;
    $dbh->{AutoCommit} = 1;
    

    This is a bit slower than the first method, but it still avoids reparsing the statement. It also avoids the subtle manipulations of the first solution, while still being atomic and allowing disk I/O to be optimized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone seen this type of IE display problem? Example http://xs133.xs.to/xs133/08465/ie_problem910.jpg.xs.jpg Note that it
Has anyone seen a good twin slider control for .Net (Win forms or WPF).
Has anyone seen this before - and can anything be done about it? This
Has anyone seen anything in Tix work under python 3.0? I've tried to work
Has anyone seen this error when trying to call an external C function from
Has anyone seen any how-to, documentation, or otherwise about how to load HTTP Modules
Has anyone seen this error when working with a PHP application out of dynamic
Has anyone seen JavaMail not sending proper MimeMessages to an SMTP server, depending on
Has anyone seen rendering glitches with Papervision? Please seee the flash movie at http://www.mapopolis.com/test/
Has anyone seen an open-source library that produces charts similar to Github.com's commit timeline

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.