to install copy Sql.pm to /System/Library/Perl/ on OS X or site-perl on other platforms.
Construction of SQL is simple with SQL.pmHQuery works like Query, but it returns an array of hashrefs instead of an array of delimited strings.
Usage:
Sql::HQuery( $dbh, $query, \@results );
To see the results, dereference the array and hash with the name of one of the fields in the select statement:
foreach my $r ( @results ) {
print $r->{ 'product_id' } . "\n";
}
Or:
print ${$results[ 0 ]}{ 'product_id' } . "\n";
Caveat: HQuery uses the names of fields as hash keys, but those names do not include the table names. So if
you do something like this:
$query = "select table1.description, table2.description, ...";
then 'description' from one table will clobber the other 'description'. The solution is to use verbose field names or to not call both of them in one select statement. Or use Sql::Query.