# used to lookup_values from the CSSD database sub lookup_NTSD_val { LogIt( $fhDEBUG, "=x" x 40 ); # so we can see the start of a new "run" LogIt( $fhDEBUG,"Entering sub:lookup_NTSD_val args: @_") if $CONFIG{DEBUG} > 3; my $cols = shift; # comma sep my $table = shift; my $criteria = shift; LogIt( $fhDEBUG,"calling: lookup( $cols, $table, $criteria);") if $CONFIG{DEBUG}>1; my $NTSDval = lookup($CONFIG{"NTSD_DB_DSN"}, $cols, $table, $criteria); LogIt( $fhDEBUG, "lookup_NTSD_val got result \"" . $NTSDval->{$cols} . "\"") if $CONFIG{DEBUG}>1; if ($NTSDval->{$cols} == ""){ ++$EVENT->{'slots'}->{'NTSD_DATA'}; } LogIt( $fhDEBUG, "NTSD_DATA now equals \"" . $EVENT->{'slots'}->{'NTSD_DATA'} . "\"") if $CONFIG{DEBUG}>1; return( $NTSDval->{ $cols }); } sub lookup { LogIt( $fhDEBUG, "Entering sub:lookup args: @_") if $CONFIG{DEBUG} > 3; my $DSN = shift; # comma sep my $cols = shift; my $table = shift; my $criteria = shift; my $LookupResult; # Let's create the Connection object used to establish the connection # my $conn = Win32::OLE->CreateObject('ADODB.Connection'); # Open a connection using the SQL Server OLE DB Provider LogIt( $fhDEBUG, "Opening ADODB connection") if $CONFIG{DEBUG} > 3; $conn->Open(< 3; # changed above line to log status of connection # LogIt( $fhDEBUG, $connStatus) if $CONFIG{DEBUG} > 3; # End of 07/04/09 changes my $sql =< 3; my $rs = $conn->Execute($sql); LogIt( $fhDEBUG, "COMPLETE: executing SQL") if $CONFIG{DEBUG} > 3; if( !defined( $rs ) ){ LogIt( $fhDEBUG,"something went wrong: ", Win32::OLE->LastError()); LogIt( $fhERROR, "something went wrong: ", Win32::OLE->LastError()); die " died something went wrong: ", Win32::OLE->LastError(),"\n"; } while( ! $rs->EOF) { my $i= 0; COL: foreach my $col (split /,/, $cols) { next COL unless $col =~ /\w+/; LogIt( $fhDEBUG,"getting val for \$col $col") if $CONFIG{DEBUG} > 3; LogIt( $fhDEBUG,"Value: ". $rs->Fields($i)->value) if $CONFIG{DEBUG} > 3; $LookupResult->{$col} = $rs->Fields($i)->value; trim( $LookupResult->{$col}); $i++; } $rs->MoveNext; } LogIt( $fhDEBUG, "Closing ADODB connection") if $CONFIG{DEBUG} > 3; $conn->Close(); ( map { LogIt( $fhDEBUG,"". $_ ) } split /\n/, Dumper $LookupResult ) if $CONFIG{DEBUG} > 3; return( $LookupResult ); } sub trim { LogIt( $fhDEBUG,"Entering sub:trim args: @_") if $CONFIG{DEBUG} > 3; for(@_) { s/^\s+//; s/\s+$//; } }