From what I see here, $rows is a hash reference, therefore:

use strict;
use warnings;

my $mySQL = SQLfunctions->new;
$mySQL->createSQLConnection("localhost\\Company", "Import");

my @results = $mySQL->runQuery("Select A,B from tablename;");

foreach my $row ( @results ) {
     foreach my $column ( keys %{$row} ) {
         printf "%s: %s\n", $column, $row->{$column};
     }
}


Sorry, don't have Win32::SqlServer on a box so the code is untested.

Cheers,
Mark


-------- Original Message  --------
Subject: Displaying Hash key/values if you don't know what they are
From: Jason Lowder <jlow...@austin.rr.com>
To: perl-win32-users@listserv.ActiveState.com
Date: Tuesday, November 17, 2009 3:15:44 PM

> Hello,
> 
> I'm using the Win32::SqlServer module to execute queries against my 
> database.
> 
> Normally a query might look like:
> 
> our $mySQL = SQLfunctions->new;
> $mySQL->createSQLConnection("localhost\\Company", "Import");
> 
> @results = $mySQL->runQuery("Select A,B from tablename;");
> 
> foreach my $rows (@results)
> {
>      print $$rows{A}."\n";
>      print $$rows{B}."\n";
> }
> 
> All values from columns A and B will be printed.
> 
> But now I want to use a query that will show me the difference between 
> two tables, Table1 and Table2.  This query is:
> 
> select 'table1' as tblName, *  from
>    (select * from table1
>     except
>     select * from table2) x
> union all
> select 'table2' as tblName, *  from
>    (select * from table2
>     except select *
>     from table1) x
> 
> Based on the return from this query, any of the columns in the table 
> could be represented.  How do I determine which keys are present so I 
> can view the results?
> 
> Thanks,
> 
> Jason
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to