Access a MSSQL Database with Perl Quickie


use strict;
use FindBin;
use lib("e:\\re\\scripts\\lib");
use vars qw($opt_h);
use Getopt::Std;
use Util;
use Logger;
use DBI;
use LWP::Simple;

if (main()) {
exit(0); # DOS Success Code
} else {
exit(1); # DOS Failure
}

sub main() {

if (! get_options()) {
log_error("Error getting options.");
return 0;
}

if ($opt_h) {
usage();
return 1;
}

my $dest_dsn_name = "pms";
my $dest_db = DBI->connect("dbi:ODBC:$dest_dsn_name", {'RaiseError' => 1, 'AutoCommit' => 0} );
# my $dest_db = DBI->connect("dbi:ODBC:$dest_dsn_name", $dest_user, $dest_password, {'RaiseError' => 1, 'AutoCommit' => 0} );
if ( ! $dest_db) {
log_error("Failed connecting to: " . $dest_db);
return 0;
}

my $sql = "";
my @result_array = $dest_db->selectrow_array($sql);
my $url = $result_array[1] . $result_array[0];

close (IN);

$dest_db->disconnect();

return 1;
}

sub get_options() {
if ( ! getopts('h') ) {
log_error("Failed getting options.");
usage();
return 0;
}

return 1;
}

sub usage() {
print "Usage.\n";
return 1;
}

This entry was posted in Code, Computers. Bookmark the permalink.

Comments are closed.