Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I would like to use place holders as well, in this case any suggestion?... my $search = "joe"; # for testing my $sql = qq{ ;with data_count as ( select sum(case when FIRST = 'joe' then 1 else 0 end) as a_count, sum(case when MIDDLE = 'joe' then 1 else 0 end) as b_count, sum(case when LAST = 'joe' then 1 else 0 end) as c_count from my_table where FIRST like 'joe%' or MIDDLE like 'joe%' or LAST like 'joe%' ) select 'Search by: ' + 'joe' union all select 'Found ' + convert(varchar, a_count) + ' ' + 'joe' + ' for Firs +t' from data_count union all select 'Found ' + convert(varchar, b_count) + ' ' + 'joe' + ' for Midd +le' from data_count union all select 'Found ' + convert(varchar, c_count) + ' ' + 'joe' + ' for Last +' from data_count }; my $sth = $dbh->prepare($sql); $sth->execute() or die "SQL Error: $DBI::errstr\n"; my $data = $sth->fetchall_arrayref({}); warn Dumper $data; ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefined value from DBI
by McA (Priest) on Sep 10, 2014 at 16:09 UTC | |
by Anonymous Monk on Sep 10, 2014 at 17:17 UTC | |
by poj (Abbot) on Sep 10, 2014 at 18:09 UTC | |
by McA (Priest) on Sep 10, 2014 at 19:50 UTC | |
|
Re: Undefined value from DBI
by erix (Prior) on Sep 10, 2014 at 20:04 UTC | |
|
Re: Undefined value from DBI
by dsheroh (Monsignor) on Sep 11, 2014 at 08:40 UTC |