Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
if($number eq "all") { $select = ''; if($fromdate || $todate) { $bet = "and CONVERT(CHAR(10),tdate,101) between '$fromda +te' and '$todate'"; #$bet = "and CONVERT(CHAR(10),tdate,101) between '?' and + '?'"; }else{ $bet = 'and tdate = (Select Max(tdate) From mytable) ord +er by tdate desc'; } }else{ $select = "and number='$number'"; if($fromdate || $todate) { $bet = "and CONVERT(CHAR(10),tdate,101) between '$fromd +ate' and '$todate'"; #$bet = "and CONVERT(CHAR(10),tdate,101) between '?' an +d '?'"; }else{ $bet = 'order by tdate desc'; } } my $all = join ( ',', ('?') x @list ); my $sql = $dbh->exec_select( "SELECT tdate,account,name FROM mytable W +HERE number in ($all) $select $bet ", @list); #my $sql = $dbh->exec_select( "SELECT tdate,account,name FROM mytable +WHERE number in ($all) $select $bet ", @list, $fromdate, $todate);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl using SQL placeholders issue
by moritz (Cardinal) on Aug 23, 2010 at 13:33 UTC |