multithreadingperlwin32ole

Perl and MS SQL thread issue


I have a Perl application on Windows which uses threads which run in parallel. Each thread accesses an MSSQL database.

I understand that I can't use Win32::OLE because it is not thread safe.

Could you suggest me some another suitable solution for doing this?

I don't know what the right way is, and what the ways to solve it might be.


Solution

  • DBI isn't dependent on anything other than the usual build and test modules that are used during installation

    There is no DBD driver for SQL Server (I'm not clear why. Perhaps someone would enlighten me?) so you will need to use an ODBC connection using the DBD::ODBC driver

    I'm unsure how DBI behaves under threads, and I suggest you use fork instead which is emulated on Windows versions of Perl. You will need to set $dbh->{AutoInactiveDestroy} = 1 to prevent processes from auto-destroying database and statement handles when they shouldn't