The data retrieved by $odbc->FetchRow() which is stored in @hydra_data doen’t seem to have spaces between the individual fields, so the my @db_info = split (/\s/, $data); can’t split the retrieved data into individual fields!In other words the line printf "%s ",$db_info[0]; would print the data with no spaces between them. i.e. if the data was AAA, BBB, CCC the output is AAABBBCCC.while ($odbc->FetchRow()) { my @hydra_data = $odbc->Data; for my $data (@hydra_data) { if ($data) { #print $data->{source_mail}; my @db_info = split (/\s/, $data); printf "%s ",$db_info[0]; } } print "\n-----------------------------------------\n"; }
#! c:/perl/bin/perl.exe -slw # $|++; require 5.008; use strict; use warnings 'all'; use Win32; use Win32::ODBC; my $dsn = "Hydra_FE"; my $qry = "qrywinbuild"; my $db = new Win32::ODBC($dsn) or die "\nError=>\t$^E : $!\n"; if (! $db) { print "\nError: $^E, ". Win32::ODBC::Error()."\n"; exit 1; } else { if ($db->sql("SELECT source_mail,hostname,machine_name FROM $qry W +HERE Business_Unit_name = '$ARGV[0]'")) { print "Error " . $db->Error() . "\n"; } else { print "\n\nObtaining $qry data from $dsn database\n\n"; while ($db->FetchRow()) { my @hydra_data = $db->Data; for my $data (@hydra_data) { if ($data) { my @db_info = split (/ /, $data); printf "%s ",$db_info[0]; } } print "\n-----------------------------------------\n"; } } } $db->Close();
In reply to $ODBC->FetchRow() question? by blackadder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |