use strict;
use warnings;
but this is some very old code I found on my machine which I slapped together to test connectivity to a MSSQL database via ODBC and did an update. I can cry when I see this code.
#! perl.exe
#Needed for ODBC access to MSSql Database
use DBI;
use DBD::ODBC;
$dbh = DBI->connect("dbi:ODBC:driver={SQL Server};server=SERVERNAME;da
+tabase=DBNAME;uid=sa;pwd=;");
my $srv = $ARGV[0];
my $new_call_num = $ARGV[1];
$idComputer = &Get_id($srv);
&Update($idComputer,$new_call_num);
exit();
##Subroutines
sub Get_id
{
$sth = $dbh->prepare("select idComputer from Computer where Name l
+ike '$srv'");
$sth->execute;
$id = $sth->fetchrow;
print "The Computer ID for $srv is $id\n";
return ($id);
}
sub Update
{
print "Update $idComputer with $new_call_num\n";
$sql = "update Alert set CustomField1 = ? where (idComputer like '
+$idComputer')";
$sth1 = $dbh->prepare($sql) || die $dbh->errstr;
$sth1->execute($new_call_num) || die $dbh->errstr;
return 1;
}
Update:When I see this I realise just how much I have learned here at perlmonks. Perhaps I should re-write this code and re-post it.. I'll see at work on Monday morning..;)
-----
Of all the things I've lost in my life, its my mind I miss the most.
|