gchatelier has asked for the wisdom of the Perl Monks concerning the following question:
I would be really appreciates explainations on what happens... Some more informations as requested,here is a simple exemple that doesn't work properly :my $conn = DBI->connect("dbi...); sub { my $conn = shift; ... }
code into somepackage :use somepackage; my $conn = somepackage::connectdb(); $conn->{AutoCommit} = 0; ... sub foo { my ($conn, $bar) = @_; my $sth = $conn->prepare(qq{ SELECT COUNT(*) AS MYCOUNT FROM MYTABLE WHERE ID=? }); $sth->execute($bar); my $ref = $sth->fetchrow_hashref(); $sth->finish(); return $ref->{MYCOUNT}; } print &foo($conn, 'some id'); ... $conn->disconnect(); __END__
Gregsub connectdb { my $user = 'user'; my $password = 'password'; my $host = 'host'; my $sid = 'SID'; return (DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $pas +sword, {PrintError => 1, RaiseError => 1, AutoCommit => 0})); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing a DBI handler the proper way
by sgifford (Prior) on Jun 14, 2006 at 14:46 UTC | |
|
Re: Passing a DBI handler the proper way
by dsheroh (Monsignor) on Jun 14, 2006 at 14:51 UTC | |
|
Re: Passing a DBI handler the proper way
by MonkE (Hermit) on Jun 14, 2006 at 14:54 UTC | |
by kwaping (Priest) on Jun 14, 2006 at 15:01 UTC | |
by albert (Monk) on Jun 14, 2006 at 15:10 UTC | |
|
Re: Passing a DBI handler the proper way
by derby (Abbot) on Jun 14, 2006 at 14:55 UTC |