Home: Perl Programming Help: DBI:
Perl threading with DBI insertion



rajni
New User

Oct 18, 2016, 12:14 AM


Views: 22541
Perl threading with DBI insertion

Hi,

I am facing problem in multithreading with perl. I have created 5 threads and executing all at a time, during data insertion in database I am facing problem here I am inserted ‘function Name’ with ‘cdets id’ . During insertion in data base mapping problem is coming. ‘Function name’ and ‘cdets id ‘ is mismatching during insert query.

Example:
I have 10 CDETS with 70 function. After threading process for 10 cdets in database results are showing 8 CDETS with 70 functions.
Here 2 CDETS are missing and its function updated in database with other cdets functions.

Note: SELECT LAST_INSERT_ID() is also not working with multithreading here.

Below is sample code:


use threads;

foreach my $id (@ddts) {

my $thread_1 = threads->create(\&ExecuteCommand, "$id");
$count1++;
if ($count1>=5){
$thread_1->join();
$count1=0;
}

}

How can I run all threads at a time by creating multiple database handlers.
Could anyone please help/guide me in troubleshooting this issue.
Any pointers would be helpful.

Thanks,
Rajni