dreman has asked for the wisdom of the Perl Monks concerning the following question:
I don't know how to use db connection for 2 different Sybase
servers within the same program.
How can I capture information
from 2 different servers. Here is a sample of the actual code.
Thanks for your ideas.
#!/usr/local/bin/perl -w use warnings; use DBD::Sybase; use DBI; sub SQL { my $parm1 = $_[0]; #sql statement my $parm2 = $_[1]; #server my $parm3 = $_[2]; #username my $parm4 = $_[3]; #password my $parm5 = $_[4]; #dbname my $parm6 = $_[5]; #task type my $parm7 = $_[6]; #object_name my ( @data, $data ); <P> </P> my $dbh=DBI->connect("dbi:Sybase:$parm2","$parm3", "$parm4" ) or die D +BI::errstr; $dbh->do("use ${parm5}"); $sth = $dbh->prepare(${parm1}); $sth->execute; while ( @data=$sth->fetchrow_array ) { print "@data\n"; } $sth->finish; $dbh->disconnect(); } ###MAIN#### &SQL("select \@\@servername", "syb_arlu9_new","testman","testman06", " +master"); sleep 10; &SQL("select \@\@servername", "syb_arlu10_new","testman","testman06", +"master");
*****************
** My Results: **
*****************
testSQL.pl syb_arlu9_new syb_arlu9_new
20061201 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: database connection output
by themage (Friar) on Nov 30, 2006 at 16:53 UTC | |
by jonadab (Parson) on Nov 30, 2006 at 17:12 UTC | |
by davorg (Chancellor) on Dec 01, 2006 at 08:58 UTC | |
|
Re: database connection output
by grep (Monsignor) on Nov 30, 2006 at 18:21 UTC | |
|
Re: database connection output
by throop (Chaplain) on Nov 30, 2006 at 17:41 UTC |