RE: perl on ncib1psrr002
edward barlow <[email protected]> Fri, 28 Mar 2008 10:58:18 -0400
| Newsgroups | gmane.comp.lang.perl.modules.dbi.general,gmane.comp.lang.perl.modules.dbi.sybase |
|---|---|
| Message-ID | <[email protected]> |
I have attached my test program for perl usage: perl GenericDBIQuery.pl -Usa -SSVR -Ppassword -Dmaster -Q'sp_who' Fair warning : for whatever reason im having problems with the program on win32 (as of - my just run 'test it before i send it') - works fine on my linux and solaris box - so it should on yours... If you cant connect try adding "-d". Ed Barlow Subject: RE: perl on ncib1psrr002 Date: Thu, 27 Mar 2008 13:53:11 -0400 From: [email protected] To: [email protected]; [email protected]; [email protected] CC: [email protected]; [email protected] Hi , We downloaded DBD::Sybase 1.08 from peppler.org and ran the necessary Makefile on our Linux host. When we ran the program (depends_analyze.pl – GEMS Ed Barlow) we are getting the errors below. We are not sure if we are missing something. Can you help us? sybase@ncib1psrr002:/home/a397179/gems/gem/ADMIN_SCRIPTS/bin> perl depends_analyze.pl -S TIER2QA -Usa -Ppassword depends_analyze.pl : run at Thu Mar 27 13:02:46 2008 OUTPUT DIRECTORY=/home/a397179/gems/gem/data/depends Had to create DBD::Sybase::dr::imp_data_size unexpectedly at /usr/lib/perl5/site_perl/5.8.3/x86_64-linux-thread-multi/DBI.pm line 1211. Had to create DBD::Sybase::db::imp_data_size unexpectedly at /usr/lib/perl5/site_perl/5.8.3/x86_64-linux-thread-multi/DBI.pm line 1241. Undefined subroutine &DBD::Sybase::db::_login called at /usr/lib/perl5/site_perl/5.8.3/x86_64-linux-thread-multi/DBD/Sybase.pm line 90. Thanks & Regards, Itta Badrinath CIB Dedicated Team DBA - Sybase Ph : 704 590 4184 Picct Group : ts-tds-cib-db-admin-sybase-invbnk Group Email : [email protected]
GenericDBIQuery.pl
(application/octet-stream, 1.3 KB)
#!/usr/local/bin/perl-5.8.2
BEGIN { $ENV{'LANG'} = 'C'; };
use strict;
use DBI;
use DBD::ODBC;
use Getopt::Std;
use Carp;
sub usage {
use File::Basename;
die "INCORRECT USAGE OF PROGRAM \nperl ".basename($0)." -U USERNAME -S SERVERNAME -P PASSWORD -D DATABASE -Q QUERY\n";
}
use vars qw ($opt_U $opt_P $opt_S $opt_D $opt_d $opt_q $opt_Q);
usage() unless getopts('U:P:S:D:dq:Q:');
usage() unless $opt_U and $opt_P and $opt_S and $opt_D;
$opt_q = $opt_Q if $opt_Q and ! $opt_q;
$opt_q = "exec sp__id" unless $opt_q;
my($Driver)="Sybase";
$Driver="ODBC" if is_nt();
print "Using dbi:$Driver:server=$opt_S\n";
DBI->trace(8) if $opt_d;
# connect to database
my $dbh = DBI->connect("dbi:$Driver:server=$opt_S", $opt_U, $opt_P)
or die $DBI::errstr;
my $sth;
my $dat;
$dbh->do("use $opt_D");
unless ($sth = $dbh -> prepare ($opt_q)) {
print("SQL command $opt_q prepare failed ");
$dbh->disconnect;
exit;
}
# excute the query
unless ( $sth -> execute ) {
print("SQL command $opt_q execute failed ");
$dbh->disconnect;
exit;
}
while ( $dat = $sth -> fetchrow_arrayref ) {
print "SUCCESS $opt_S ".join(" ",@$dat),"\n";
}
$sth ->finish;
$dbh->disconnect;
exit;
sub is_nt {
return 1 if $^O =~ /MSWin32/;
return 0;
}