On Tue, May 21, 2002 at 09:22:23AM -0400, [EMAIL PROTECTED] wrote:
> Okay thanks, I added "my $dbh;" prior to the subroutine and am still
> receiving the same error. Here is the code:
Adding a my $dbh outside the subroutine doesn't change the fact that you
still have $dbh lexically scoped inside the subroutine:
> sub db_connect
> {
> use DBI;
> use strict;
>
> my $db_connect = 'DUMY';
> my $dbh = DBI->connect("dbi:Oracle:$db_connect","FMC","FMC")
> or die "Database connection not made: $DBI::errstr";
> }
You could simply change this to:
$dbh = DBI->connect( ... ) or die "...";
to assign to the $dbh which you declare at the top of the file, but it
would probably be better for the subroutine to return the database handle.
use strict;
use DBI;
my $dbh = db_connect();
sub db_connect {
my $db_connect = 'DUMY';
my $dbh = DBI->connect("dbi:Oracle:$db_connect","FMC","FMC")
or die "Database connection not made: $DBI::errstr";
}
Ronald