poqui has asked for the wisdom of the Perl Monks concerning the following question:
my $dbh; sub connectdb {# connect to database using 3 parameters; return databa +se handle my ($dbstring, $dbdepot, $password) = @_; print "attempt to connect to database $dbstring :$dbdepot\n"; system "time /T"; my $dbhi = DBI->connect($dbstring,$dbdepot,$password, { AutoCommit => 0, RaiseError => 1, PrintError => 1 }) or warn "can't connect to database $dbstring :$dbdepot :", $DB +I::errstr, "\n"; if (defined ($dbhi)) { print "success: $dbhi \n"; return $dbhi; } else { print "Failure\n"; return -1; } } while (($dbh = connectdb($dwqa1,$depot,$pswd) eq -1) && ($sleepcount < + $sleeplimit)) { sleep ($sleepdur); ++$sleepcount; } my $sth = $dbh->prepare("select '$depot', t.table_name, column_name fr +om user_tables t, user_tab_columns c where c.table_name = t.table_nam +e"); $sth->execute();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI: pass $dbh from a sub
by nobull (Friar) on Jul 29, 2004 at 16:52 UTC | |
|
Re: DBI: pass $dbh from a sub
by dsb (Chaplain) on Jul 29, 2004 at 16:13 UTC | |
|
Re: DBI: pass $dbh from a sub
by periapt (Hermit) on Jul 29, 2004 at 16:38 UTC | |
by poqui (Deacon) on Jul 29, 2004 at 19:57 UTC | |
|
Re: DBI: pass $dbh from a sub
by mifflin (Curate) on Jul 29, 2004 at 16:20 UTC | |
by iburrell (Chaplain) on Jul 29, 2004 at 16:27 UTC | |
by runrig (Abbot) on Jul 29, 2004 at 20:39 UTC | |
by mifflin (Curate) on Jul 30, 2004 at 00:16 UTC | |
by mifflin (Curate) on Jul 29, 2004 at 16:50 UTC | |
by poqui (Deacon) on Jul 29, 2004 at 19:53 UTC | |
by runrig (Abbot) on Jul 29, 2004 at 20:44 UTC | |
by poqui (Deacon) on Jul 30, 2004 at 14:08 UTC |