Hey guys, my second "contribution" tonight...
Because I had problems with EasyDBI I tried to write a similar script to use
SimpleDBI, but it dies:
Undefined subroutine &POE::Component::SimpleDBI::SubProcess::main called at
C:/Perl/site/lib/POE/Component/SimpleDBI.pm line 810.
Here's a copy of the script, and various version numbers.
SubProcess.pmdoes clearly have a main(), and
SimpleDBI.pm seems to be referencing it ok as far as I can tell....
Thanks in advance for any advice,
#!/usr/bin/perl
use strict;
use warnings;
use POE;
use POE::Component::SimpleDBI;
use Data::Dumper;
$Data::Dumper::Maxdepth = 1;
POE::Component::SimpleDBI->new( 'db1' ) or die "Unable to create the 'db1'
DBI session";
POE::Component::SimpleDBI->new( 'db2' ) or die "Unable to create the 'db2'
DBI session";
POE::Session->create(
inline_states => {
_start => sub {
# Connect
print '[' . localtime() . "] connecting to 'db1'\n";
$_[KERNEL]->post( 'db1', 'CONNECT',
'DSN' => 'dbi:ODBC:Sybase.db1',
'USERNAME' => 'user',
'PASSWORD' => 'pass',
'EVENT' => 'conn_handler',
);
print '[' . localtime() . "] connecting to 'db2'\n";
$_[KERNEL]->post( 'db2', 'CONNECT',
'DSN' => 'dbi:ODBC:Sybase.db2',
'USERNAME' => 'user',
'PASSWORD' => 'pass',
'EVENT' => 'conn_handler',
);
# Query
print '[' . localtime() . "] initiating db1 query\n";
$_[KERNEL]->call( 'db1', 'MULTIPLE',
'SQL' => 'select * from table where
foo = ?',
'PLACEHOLDERS' => [ 'bar' ],
'EVENT' => 'db1_result_handler',
);
print '[' . localtime() . "] initiating db2 query\n";
$_[KERNEL]->call( 'db2', 'MULTIPLE',
'SQL' => 'select * from table where
foo = ?',
'PLACEHOLDERS' => [ 'bar' ],
'EVENT' => 'db2_result_handler',
);
},
conn_handler => sub {
my ($session_alias) = $_[KERNEL]->alias_list( $_[SESSION] );
print '[' . localtime() . "] connection to $session_alias
complete\n";
print Dumper $_[ARG0];
},
db1_result_handler => sub {
#my %success_hash = %{ $_[ARG0] };
print '[' . localtime() . "] db1 query complete\n";
print Dumper $_[ARG0];
$_[KERNEL]->post( db1 => 'shutdown' );
},
db2_result_handler => sub {
#my %success_hash = %{ $_[ARG0] };
print '[' . localtime() . "] db2 query complete\n";
print Dumper $_[ARG0];
$_[KERNEL]->post( db2 => 'shutdown' );
},
},
);
$poe_kernel->run();
__END__
Versions:
Perl - 5.8.7 built for MSWin32 [build 813]
POE - 0.9500
SimpleDBI - 1.15
POE::Component::SimpleDBI::SubProcess - 1.09
--
-jp
Chuck Norris thought up some of the funniest Chuck Norris facts ever, but he
hasn't submitted them to the site because he doesn't believe in any form of
submission.