-# pass $sth and sql_params, get back an executable query
-sub get_prepped_report {
- my ($sql, $param_names, $sql_params ) = @_;
- my %lookup;
- @lookup{@$param_names} = @$sql_params;
- my @split = split /<<|>>/,$sql;
- my @tmpl_parameters;
- for(my $i=0;$i<$#split/2;$i++) {
- my $quoted = @$param_names ? $lookup{ $split[$i*2+1] } : @$sql_params[$i];
- # if there are special regexp chars, we must \ them
- $split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g;
- if ($split[$i*2+1] =~ /\|\s*date\s*$/) {
- $quoted = output_pref({ dt => dt_from_string($quoted), dateformat => 'iso', dateonly => 1 }) if $quoted;
- }
- $quoted = C4::Context->dbh->quote($quoted);
- $sql =~ s/<<$split[$i*2+1]>>/$quoted/;
- }
- return $sql;
-}