in reply to how to save data to new array after retrieving from sql server
selectall_arrayref() combines "prepare", "execute" and "fetchall_arrayref" into a single call. It returns a reference to an array containing a reference to an array for each row of data fetched.
Also, you could remove the trailing spaces with RTRIM
poj#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use DBI; # establish the connection my $dbh = DBI->connect('dbi:ODBC:myDSN','username','userpassword', { RaiseError => 1, PrintError => 1 } ) or die "Could not connect to database: $DBI::errstr"; # sql query statement my $sql =<< "SQL"; SELECT RTRIM(location),RTRIM(CompletionStatus) FROM ewNetworkFaults WHERE Type like '%Audio Visual%' AND CompletionStatus not like '%Completed%' SQL my $table = $dbh->selectall_arrayref($sql); print Dumper($table);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to save data to new array after retrieving from sql server
by mhoang (Acolyte) on Jul 28, 2017 at 01:36 UTC | |
by poj (Abbot) on Jul 28, 2017 at 06:34 UTC | |
by mhoang (Acolyte) on Aug 02, 2017 at 02:50 UTC | |
by poj (Abbot) on Aug 02, 2017 at 06:04 UTC | |
by mhoang (Acolyte) on Aug 02, 2017 at 23:35 UTC | |
by AnomalousMonk (Archbishop) on Jul 28, 2017 at 07:22 UTC |