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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:39:21+00:00 2026-05-26T07:39:21+00:00

Has anyone ever try to use DB2 import from within a Perl program? My

  • 0

Has anyone ever try to use DB2 import from within a Perl program?

My application is inserting 10 million of rows and apparently connecting using DBI and doing the insert row by row takes forever.

DB2 import/load from the command line works great, however is there a better way rather than to call a system call from the Perl program to invoke:

use IPC::System::Simple qw( systemx );
use autodie;

systemx( "db2 connect ..." );
systemx( "db2 import ..." );
etc?

thanks!

  • 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-26T07:39:22+00:00Added an answer on May 26, 2026 at 7:39 am

    I have actually had exactly the problem you seem to be having. It seems that on some systems you have to explicitly perform a DB2 Connect prior to being able to import.

    In fact, I found my scripts behaved the most consistently when I had a DB2 Connect string immediately prior to my import statement, but that may be a system dependent issue.

    Suggested solution:

    I started out with a connection statement like the following. Checking that this statement will work also allows for a confirmation that your DB path is valid.

    db2 connect to $DB_NAME user $DB_USER using $DB_PASS

    I ended up saving the string above as $connnection_starter since you will be using it in several places.

    I then made a system call like the following:

    system($con_starter . "; db2 import from $temp_file_path of del commitcount 5000 $insert_update_setting into tablespace.$table_name");

    The commitcount value is not necessarily needed in your case, (although it is generally well suited to very large imports) but I would suggest using it since it causes DB2 to log a message on the status of the import every 5000 records if you are running the script via the command-line/shell.

    Error Checking

    You can pull in the value of $? to see if an error was produced during the import command, since it should have a return of 0 if the behavior was correct.

    Annoyingly, the other return codes are not very helpful. I set up my import command to log the exact statement in case of a failure, so that I could manually review that at a later point:

    if ($? ne 0){
        $logger->warn("Failed to import $temp_file_path to table $table_name \nError: $?");
        $logger->warn("Exact statement: \t " . $con_starter . "; db2 import from $temp_file_path of del commitcount 5000 $insert_update_setting into tablespace.$table_name");
    

    Hopefully that helps!

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

Sidebar

Related Questions

Has anyone ever used the Bridge pattern in a real world application? If so,
Has anyone ever tried to use custom binding with SSL in a WCF web
Has anyone ever launched cloud-based apps / websites that use a local SQLite DB
Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project?
Has anyone ever heard of a UNIX shell written in a reasonable language, like
Has anyone ever done work to get Ruby to do continuations (like Seaside on
Has anyone ever tried, or had any success at getting Wascana (Eclipse CDT +
Has anyone ever seen the storage class auto explicitly used in C/C++? If so,
Has anyone ever modified the post-new.php file in their WordPress installation? I want to
has anyone ever tried to get the list of all the movieclips (even the

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.