http://www.perlmonks.org?node_id=11115668

maria80e has asked for the wisdom of the Perl Monks concerning the following question:

I have executed the stored procedure manually which retrieves 45 records where as while executing it through below perl script, it fetches only one record and that record is not the top or last record of 45 records. Whats wrong in the below code. Need support on this.

Platform :Windows Database :MS SQL SERVER

**Program**:

use strict; use DBI; use DBD::ODBC; print "Trying to connect\n"; my $server_name = "XXXXXXXX"; my $server_port = 'NNNN'; my $database_name = 'XXXXX'; my $database_user = 'XX'; my $database_pass = 'XXXXX'; my $dbh = DBI->connect("dbi:ODBC:DSN=sql_test", $database_user, $datab +ase_pass) || die "Couldn't open database: $DBI::errstr\n"; my $sql = $dbh->prepare("Exec sp_listUsers '25329601','1'"); my $more_results; $sql->execute(); my $results_ref; my @array; do { print "getting results\n"; my $names = $sql->{NAME}->[0]; print "names $names\n"; while ($results_ref = $sql->fetchrow_hashref()) { print "test $results_ref->{'user_id'}\n"; print join (", ", values %$results_ref), "\n"; push (@array, $results_ref->{'user_id'}); #print "row $results_ref\n"; } }while($more_results = $sql->{odbc_more_results}); foreach my $val (@array) { print "user id $val\n"; } $dbh->disconnect();