|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Passing a $dbh to a subroutine
Date: Sep 18 1997 3:35PM
salvatore.sferrazza@ny.ubs.com wrote:
>
> Can this be done? Right now in a majority of my applications I write
> subs to carry out inserts, updates, selects, etc.. Each one of these
> subs opens/keeps its own $dbh that is closed automatically when the
> sub exits. In order to avoid the overhead of opening/closing the
> connection and re-specifying the connection params each time, can I
> just pass the $dbh to the sub and access it that way?
Yes, absolutely:
my $dbh = new Sybase::DBlib;
do_insert($dbh);
sub do_insert {
my $dbh = shift;
$dbh->dbcmd(...);
$dbh->dbsqlexec; $dbh->dbresults;
}
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
|