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 8538307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:06:10+00:00 2026-06-11T11:06:10+00:00

I am trying to insert multiple values to the same field using a single

  • 0

I am trying to insert multiple values to the same field using a single query. Are there any mistakes in the following code?

my $dbh =  DBI->connect("DBI:mysql:accounting:localhost", 'username', 'password',
      {RaiseError => 1});
my @id = [1,18,976,90];
my @name = ['ss','dc','ws','rd'];
my @data = ([@id],[@name]);
my $ab = $dbh->prepare("insert into table (id,name) values (?,?)";);
for my $datam (@data) {
  $ab->execute(@$datam);
}
$ab->finish();

I am getting the following error: DBI::st=HASH(0*a16f774) for prepare statement. What could be causing this?

  • 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-06-11T11:06:11+00:00Added an answer on June 11, 2026 at 11:06 am

    Can’t really answer your question since you didn’t actually give the error, but I have spotted a problem with your code. You’re doing

    $ab->execute([1,18,976,90]);
    $ab->execute(['ss','dc','ws','rd']);
    

    when you obviously want to do

    $ab->execute(  1, 'ss');
    $ab->execute( 18, 'dc');
    $ab->execute(976, 'ws');
    $ab->execute( 90, 'rd');
    

    Fix:

    my @id = (1,18,976,90);
    my @name = ('ss','dc','ws','rd');
    
    for my $i (0..$#id) {
       $ab->execute($id[$i], $name[$i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a query that will insert multiple values from my
i'm trying to insert multiple data using a query, i've tried the implode function,
I got the following issue while trying to insert multiple entries into a MySQL
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
I been trying all day to do multiple insert for the same form based
I'm trying to insert multiple times this same key into map but with different
i was trying to insert a string into database having multiple value using componentsSeparatedByString:@,.
I'm trying to insert multiple rows using SqlCommand from C# to SQL Server. I'm
I'm very new to C# and trying to insert multiple values to an access
I am trying to insert multiple rows in a listitems to a database using

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.